作者 郭文星

123

@@ -94,45 +94,22 @@ class Index extends Api @@ -94,45 +94,22 @@ class Index extends Api
94 * 公众号推送审核信息给经纪人 94 * 公众号推送审核信息给经纪人
95 */ 95 */
96 public function senWxmsgToAgentUser($titdesc="", $remark="") 96 public function senWxmsgToAgentUser($titdesc="", $remark="")
97 - { $appId = 'wxb7dd0c03865a94e0';  
98 - $appSecret = '6af75a6fb8211da45631630e34769f82';  
99 - $openId = 'oYhYi6fEAxSnlAV1qNm2BwaJdQOQ';  
100 - $unionId = 'ojyUX6oNFoQMqoCd1JWtfwQs-CeA';  
101 - // 获取token  
102 - $myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appId . "&secret=" . $appSecret;  
103 - $json_token = http_request($myurl);  
104 - $access_tokens = json_decode($json_token, true);  
105 - $accessToken = $access_tokens['access_token'];  
106 -// 发送消息的接口地址  
107 - $sendMessageUrl = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$accessToken}";  
108 -  
109 -// 构造要发送的消息数据  
110 - $data = [  
111 - 'touser' => $openId,  
112 - 'msgtype' => 'text',  
113 - 'text' => [  
114 - 'content' => '你好,这是一个公众号消息'  
115 - ]  
116 - ];  
117 -  
118 -// 对数据进行JSON编码  
119 - $jsonData = json_encode($data, JSON_UNESCAPED_UNICODE);  
120 -  
121 -// 发送HTTP POST请求  
122 - $ch = curl_init();  
123 - curl_setopt($ch, CURLOPT_URL, $sendMessageUrl);  
124 - curl_setopt($ch, CURLOPT_POST, true);  
125 - curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);  
126 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
127 - $response = curl_exec($ch);  
128 - curl_close($ch);  
129 -  
130 -// 处理响应结果  
131 - $result = json_decode($response, true);  
132 - if ($result['errcode'] == 0) {  
133 - echo "消息发送成功";  
134 - } else {  
135 - echo "消息发送失败,错误代码:{$result['errcode']},错误信息:{$result['errmsg']}"; 97 + {
  98 + $wxopenid="oYhYi6fEAxSnlAV1qNm2BwaJdQOQ";
  99 + $sendInfo = array(
  100 + 'first' => array('value' => "123123", 'color' => "#743A3A"),
  101 + 'thing2' => array('value' => "123123", 'color' => '#173177'),
  102 + 'time3' => array('value' =>urlencode(date('Y-m-d H:i:s', time())), 'color' => '#173177'),
  103 + 'thing7' => array('value' =>"123123", 'color' => '#173177'),
  104 + 'phone_number5' => array('value' => "123123123", 'color' => '#173177'),
  105 + );
  106 + if ($wxopenid) {
  107 + $config = get_addon_config('wechat');
  108 + $tourl = 'https://fdc.xp.yn.cn/h5/';
  109 + $ywt_appid = 'wx9f73637c6b8f2c47';
  110 + $pagepath = 'pages/home/index';
  111 + $res = sendAstuWxMsgToAgent($sendInfo, $wxopenid, $tourl, $config['app_id'], $config['secret'], $ywt_appid, $pagepath);
  112 + //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);
136 } 113 }
137 } 114 }
138 function http_request($url, $data = array()) 115 function http_request($url, $data = array())