作者 郭文星

123

... ... @@ -94,56 +94,47 @@ class Index extends Api
*/
public function senWxmsgToAgentUser($titdesc="", $remark="")
{
$wxopenid="o5ABA4yWDTLRTf3LkBMMHoV7XOvQ";
$sendInfo = array(
'first' => array('value' => urlencode($titdesc), 'color' => "#743A3A"),
'keyword1' => array('value' => urlencode(date('Y-m-d H:i:s', time())), 'color' => '#173177'),
'keyword2' => array('value' => urlencode('企业入驻'), 'color' => '#173177'),
'remark' => array('value' => urlencode($remark), 'color' => '#173177'),
);
if ($wxopenid) {
$config = get_addon_config('wechat');
$tourl = 'https://wyc.tenyes.cn/h5/';
$ywt_appid = 'wxb7dd0c03865a94e0';
$pagepath = 'pages/home/index';
$res = $this->sendAstuWxMsgToAgent($sendInfo, $wxopenid, $tourl, $config['app_id'], $config['secret'], $ywt_appid, $pagepath);
return $res;
//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 sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath)
{
$myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
$json_token = $this->http_request($myurl);
$access_tokens = json_decode($json_token, true);
$access_token = $access_tokens['access_token'];
$template = array(
'touser' => $openid, //
'template_id' => 'zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8', //模板消息id 必须修改
'url' => $tourl, //点击链接
"miniprogram" => [
"appid" => $ywt_appid,
"pagepath" => $pagepath
$appid = 'wxb7dd0c03865a94e0';//公众号的appid
$secret = '6af75a6fb8211da45631630e34769f82';
// 获取token
$token=$this->getAccToken($appid,$secret);
//$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;
$data = [
"touser"=>"o5ABA4yWDTLRTf3LkBMMHoV7XOvQ",
"appid"=>$appid,//公众号
//"template_id"=>"nVfy1Tz1EXQ3T2YcGkwgicAjrD0M3N1Ca-CHIJCwjQY",//模板id
"template_id"=>"zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8",//模板id
"url"=>"",
"miniprogram"=>[
"appid"=>"wx58ceff4e93cfc523",//小程序
//"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
],
'topcolor' => "#173177",
'data' => $info
);
$json_template = json_encode($template);
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;
$json = $this->http_request($url, urldecode($json_template));
print_r($json);return;
$rs = json_decode($json, true);
return $rs;
"data"=>[
'thing2' => array(
'value'=>"行程",
'color'=>''
),
'time3'=>array(
'value'=>"2024-06-19",
'color'=>''
),
'thing7'=>array(
'value'=>"出发地",
'color'=>''
),
'phone_number5'=>array(
'value'=>"联系方式",
'color'=>''
),
],
];
return $this->http_request($url,json_encode($data)); //发送请求
}
function http_request($url, $data = array())
{
... ...