...
|
...
|
@@ -94,54 +94,46 @@ class Index extends Api |
|
|
* 公众号推送审核信息给经纪人
|
|
|
*/
|
|
|
public function senWxmsgToAgentUser($titdesc="", $remark="")
|
|
|
{
|
|
|
|
|
|
$appid = 'wx58ceff4e93cfc523';//公众号的appid
|
|
|
$secret = 'baf744d21875280a5e98611f66adaf91';
|
|
|
{$appId = 'wxb7dd0c03865a94e0';
|
|
|
$appSecret = '6af75a6fb8211da45631630e34769f82';
|
|
|
$openId = 'o5ABA4yWDTLRTf3LkBMMHoV7XOvQ';
|
|
|
$unionId = 'ojyUX6oNFoQMqoCd1JWtfwQs-CeA';
|
|
|
// 获取token
|
|
|
$myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
|
|
|
$json_token = http_request($myurl);
|
|
|
$access_tokens = json_decode($json_token, true);
|
|
|
$token = $access_tokens['access_token'];
|
|
|
$params = [];
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $token . "&openid=" . "o5ABA4yWDTLRTf3LkBMMHoV7XOvQ" . "&lang=zh_CN";
|
|
|
$userInfo = Http::sendRequest($url, $params, 'GET');
|
|
|
print_r($userInfo);return;
|
|
|
//$url = "https://api.weixin.qq.com/cgi-bin/message/wxopen/template/uniform_send?access_token=".$token;
|
|
|
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$token;
|
|
|
$accessToken = $access_tokens['access_token'];
|
|
|
// 发送消息的接口地址
|
|
|
$sendMessageUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$accessToken}";
|
|
|
|
|
|
// 构造要发送的消息数据
|
|
|
$data = [
|
|
|
"touser"=>"o5ABA4yWDTLRTf3LkBMMHoV7XOvQ",
|
|
|
"appid"=>$appid,//公众号
|
|
|
//"template_id"=>"nVfy1Tz1EXQ3T2YcGkwgicAjrD0M3N1Ca-CHIJCwjQY",//模板id
|
|
|
"template_id"=>"zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8",//模板id
|
|
|
"url"=>"",
|
|
|
"miniprogram"=>[
|
|
|
"appid"=>$appid,//小程序
|
|
|
//"pagepath"=>"/pagesIndex/house/billingDetails?type=3&house_user_id=" . $house_user_id . "&house_code_id=" . $house_code_id//pagesIndex/house/billingDetails 未收账单路径 index?foo=bar
|
|
|
"pagepath"=>""//pagesIndex/house/billingDetails 未收账单路径 index?foo=bar
|
|
|
],
|
|
|
"data"=>[
|
|
|
'thing2' => array(
|
|
|
'value'=>"行程",
|
|
|
'color'=>''
|
|
|
),
|
|
|
'time3'=>array(
|
|
|
'value'=>"2024-06-19",
|
|
|
'color'=>''
|
|
|
),
|
|
|
|
|
|
'thing7'=>array(
|
|
|
'value'=>"出发地",
|
|
|
'color'=>''
|
|
|
),
|
|
|
'phone_number5'=>array(
|
|
|
'value'=>"联系方式",
|
|
|
'color'=>''
|
|
|
),
|
|
|
],
|
|
|
'touser' => $unionId,
|
|
|
'msgtype' => 'text',
|
|
|
'text' => [
|
|
|
'content' => '你好,这是一个公众号消息'
|
|
|
]
|
|
|
];
|
|
|
return $this->http_request($url,json_encode($data)); //发送请求
|
|
|
|
|
|
// 对数据进行JSON编码
|
|
|
$jsonData = json_encode($data, JSON_UNESCAPED_UNICODE);
|
|
|
|
|
|
// 发送HTTP POST请求
|
|
|
$ch = curl_init();
|
|
|
curl_setopt($ch, CURLOPT_URL, $sendMessageUrl);
|
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
$response = curl_exec($ch);
|
|
|
curl_close($ch);
|
|
|
|
|
|
// 处理响应结果
|
|
|
$result = json_decode($response, true);
|
|
|
if ($result['errcode'] == 0) {
|
|
|
echo "消息发送成功";
|
|
|
} else {
|
|
|
echo "消息发送失败,错误代码:{$result['errcode']},错误信息:{$result['errmsg']}";
|
|
|
}
|
|
|
}
|
|
|
function http_request($url, $data = array())
|
|
|
{
|
...
|
...
|
|