...
|
...
|
@@ -94,45 +94,22 @@ class Index extends Api |
|
|
* 公众号推送审核信息给经纪人
|
|
|
*/
|
|
|
public function senWxmsgToAgentUser($titdesc="", $remark="")
|
|
|
{ $appId = 'wxb7dd0c03865a94e0';
|
|
|
$appSecret = '6af75a6fb8211da45631630e34769f82';
|
|
|
$openId = 'oYhYi6fEAxSnlAV1qNm2BwaJdQOQ';
|
|
|
$unionId = 'ojyUX6oNFoQMqoCd1JWtfwQs-CeA';
|
|
|
// 获取token
|
|
|
$myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appId . "&secret=" . $appSecret;
|
|
|
$json_token = http_request($myurl);
|
|
|
$access_tokens = json_decode($json_token, true);
|
|
|
$accessToken = $access_tokens['access_token'];
|
|
|
// 发送消息的接口地址
|
|
|
$sendMessageUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$accessToken}";
|
|
|
|
|
|
// 构造要发送的消息数据
|
|
|
$data = [
|
|
|
'touser' => $openId,
|
|
|
'msgtype' => 'text',
|
|
|
'text' => [
|
|
|
'content' => '你好,这是一个公众号消息'
|
|
|
]
|
|
|
];
|
|
|
|
|
|
// 对数据进行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']}";
|
|
|
{
|
|
|
$wxopenid="oYhYi6fEAxSnlAV1qNm2BwaJdQOQ";
|
|
|
$sendInfo = array(
|
|
|
'first' => array('value' => "123123", 'color' => "#743A3A"),
|
|
|
'thing2' => array('value' => "123123", 'color' => '#173177'),
|
|
|
'time3' => array('value' =>urlencode(date('Y-m-d H:i:s', time())), 'color' => '#173177'),
|
|
|
'thing7' => array('value' =>"123123", 'color' => '#173177'),
|
|
|
'phone_number5' => array('value' => "123123123", 'color' => '#173177'),
|
|
|
);
|
|
|
if ($wxopenid) {
|
|
|
$config = get_addon_config('wechat');
|
|
|
$tourl = 'https://fdc.xp.yn.cn/h5/';
|
|
|
$ywt_appid = 'wx9f73637c6b8f2c47';
|
|
|
$pagepath = 'pages/home/index';
|
|
|
$res = sendAstuWxMsgToAgent($sendInfo, $wxopenid, $tourl, $config['app_id'], $config['secret'], $ywt_appid, $pagepath);
|
|
|
//file_put_contents("pcl_wct_send.log", date("Y-m-d H:i:s") . "1-2-" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
|
|
|
}
|
|
|
}
|
|
|
function http_request($url, $data = array())
|
...
|
...
|
|