首页 > 微信 > 详细

微信接口-发送内容到指定用户

时间:2015-08-21 10:50:39      阅读:394      评论:0      收藏:0      [点我收藏+]

function wx_sendtext($openid,$text,$appId,$appSecret) {

  $access_token = get_access_token($appId,$appSecret);
  $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=$access_token";
  $data_string = ‘{"touser":"‘.$openid.‘","msgtype":"text","text":{"content":"‘.$text.‘"}}‘;

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json; charset=utf-8‘,‘Content-Length: ‘ . strlen($data_string)));
  ob_start();
  curl_exec($ch);
  $return_content = ob_get_contents();
  ob_end_clean();

  $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

  return array($return_code, $return_content);
}

发送内容到指定用户,直接输入内容和对应openid

 

希望各位大神能帮我的代码继续优化

微信接口-发送内容到指定用户

原文:http://www.cnblogs.com/zzw6105php/p/4747079.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!