需求:在他人扫码成功后向双方发送模板通知(已关注公众号的用户扫码之后即可成功,未关注的用户扫码之后要同意关注公众号之后才算成功,否则不算)
put_tongzhi.php
<?php
//include('token.php');//获取access_token已在反馈文件中引入
function put_tongzhi($openid,$act_id){ //发送通知给发起组团的人(团长),通知有人入团
$token = getToken();
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$token;
$data = array(
"touser" => $openid,
"template_id" => "Xi0VIam4zjQRm2qiPVzl-u5D_12YyPdqXSU-Lucce-Q",//测试模板id
"url" =>"http:/*****ges/rule.php?openid=".$openid."&act_id=".$act_id, //团长活动个人中心查看入团人员
"data" => array(
"child" => array(
"value" => "您好友",
)
)
);
$info = json_decode(curl_post($url,json_encode($data)),true);
return $info;
}
function put_my_tongzhi($openid){ //发送通知给发起入团的人(团员),通知你已入团
$token = getToken();
$url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$token;
$data = array(
"touser" => $openid,
"template_id" => "28wY9b1RPE6y7lEyusWMMn18-7WrqMSCWzHhMq-1ynA",
"url" =>"",
"data" => array(
"child" => array(
"value" => " ",
)
)
);
$info = json_decode(curl_post($url,json_encode($data)),true);
return $info;
}
function get_user($openid){ //获取微信用户信息方法(公用方法)此处用的是批量获取的接口
$token = getToken();
$url = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=".$token;
$people_arr[]['openid'] = $openid;
$data = array(
"user_list" => $people_arr
);
$info = json_decode(curl_post($url,json_encode($data)),true);
return $info;
}
?>