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

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

 

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

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

上一篇:WEB安全漏洞扫描与处理(下)——安全报告分析和漏洞处理


下一篇:ViewPage和Fragment上 实现BadgeView消息提醒(仿旧微信)