<meta charset="utf-8">
<?PHP
function getcfg(){$cfg['getAccessTokenUrl']='xxxx/send_msg.php';$cfg['appid']='xxx';$cfg['appsecret']='xxx';return $cfg;
}
$cfg = getcfg();$access_token_url = '=client_credential&appid='.$cfg['appid'].'&secret='.$cfg['appsecret'];
$at = file_get_contents($access_token_url);$at = json_decode($at,true);$post_msg_url = '='.$at['access_token'];$post_msg_data = array('touser'=>array('xxx','xxx'), 'msgtype'=>'text','text'=>array('content'=>'hello from boxer')
);
$json_msg_data = json_encode($post_msg_data);//$ch = curl_init();//设置超时curl_setopt($ch, CURLOPT_TIMEOUT, 30);curl_setopt($ch, CURLOPT_URL, $post_msg_url);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);curl_setopt($ch, CURLOPT_HEADER, 0); //设置headercurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上curl_setopt($ch, CURLOPT_POST, 1); //post提交方式curl_setopt($ch, CURLOPT_POSTFIELDS, urldecode($json_msg_data));//运行curl,结果以jason形式返回$data = curl_exec($ch);curl_close($ch);print_r($data);exit;
//?>
预览发送内容
<?PHP session_start(); error_reporting(0);?>
<meta charset="utf-8">
<?PHP
function getcfg(){$cfg['getAccessTokenUrl']='xxxxxxxx/send_msg.php';$cfg['appid']='xxxxxx';$cfg['appsecret']='xxxxx';return $cfg;
}
$cfg = getcfg();$access_token_url = '=client_credential&appid='.$cfg['appid'].'&secret='.$cfg['appsecret'];
$at = file_get_contents($access_token_url);$at = json_decode($at,true);//$post_msg_url = '='.$at['access_token'];
$post_msg_url = '='.$at['access_token'];$post_msg_data = array('touser'=>'xx-xx-xxxxxxx', 'msgtype'=>'text','text'=>array('content'=>'hello from 发士大夫<a href="">s是s发</a>')
);
$json_msg_data = json_encode($post_msg_data);$json_msg_data = '{"touser":"oEXy-xxx-xxx","msgtype":"text","text":{"content":"您的优惠券即将过期请尽快使用 n <a href="">点击查看我的优惠券</a>"}}';//echo urldecode($json_msg_data);exit;//$ch = curl_init();//设置超时curl_setopt($ch, CURLOPT_TIMEOUT, 30);curl_setopt($ch, CURLOPT_URL, $post_msg_url);curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);curl_setopt($ch, CURLOPT_HEADER, 0); //设置headercurl_setopt($ch, CURLOPT_HTTPHEADER, array("content-type: application/x-www-form-urlencoded; charset=UTF-8"));curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上curl_setopt($ch, CURLOPT_POST, 1); //post提交方式curl_setopt($ch, CURLOPT_POSTFIELDS, ($json_msg_data));//运行curl,结果以jason形式返回$data = curl_exec($ch);curl_close($ch);print_r($data);exit;
//?>
本文发布于:2024-01-28 00:11:32,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/17063718923482.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |