微信公众号 PHP开发三 (二维码转发,他人扫码成功入团后发送公众号通知)

需求:在他人扫码成功后向双方发送模板通知(已关注公众号的用户扫码之后即可成功,未关注的用户扫码之后要同意关注公众号之后才算成功,否则不算)

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;
}
?>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值