微信公众号二次开发

<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$touserName = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$keywords = $postObj->Content;
$textTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Content><![CDATA[%s]]></Content>
			</xml>";

$musicTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Music>
			<Title><![CDATA[%s]]></Title>
			<Description><![CDATA[%s]]></Description>
			<MusicUrl><![CDATA[%s]]></MusicUrl>
			<HQMusicUrl><![CDATA[%s]]></HQMusicUrl>
			</Music>
			</xml>";
$newsTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<ArticleCount>1</ArticleCount>
			<Articles>
			<item>
			<Title><![CDATA[%s]]></Title>
			<Description><![CDATA[%s]]></Description>
			<PicUrl><![CDATA[%s]]></PicUrl>
			<Url><![CDATA[%s]]></Url>
			</item>
			</Articles>
			</xml>";

//关注事件回复
if($postObj->MsgType == 'event'){
	if($postObj->Event == 'subscribe'){
		$msgType = 'news';
		$title = '三月三!!!!';
		$des = '好日子,欢迎你的到来!!!!';
		$picurl = 'http://boolceshi.ittun.com/xie.jpg';
		$url = 'http://www.zixue.it';
		$resultful = sprintf($newsTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$picurl,$url);
		echo $resultful;
	}elseif($postObj->Event == 'CLICK'){
		if($postObj->EventKey == '音乐'){
		$msgType = 'music';
		$title = '许嵩';
		$des = '好听,唯美';
		$url = 'http://boolceshi.ittun.com/22.mp3';
		$resultful = sprintf($musicTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$url,$url);
		echo $resultful;
		}
	}
}			

//关键词自动回复
if($postObj->MsgType == "text" ){
	if($postObj->Content == '1'){
		$content = '你好!!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($postObj->Content == '你好'){
		$content = '欢迎你来到布尔教育!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($keywords == '音乐'){
		$msgType = 'music';
		$title = '许嵩';
		$des = '好听,唯美';
		$url = 'http://boolceshi.ittun.com/22.mp3';
		$resultful = sprintf($musicTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$url,$url);
		echo $resultful;
	}elseif($keywords == '图文'){
		$msgType = 'news';
		$title = '微信公开课!!!';
		$des = '好听,好学,好玩!!!';
		$picurl = 'http://boolceshi.ittun.com/bool.jpg';
		$url = 'http://www.baidu.com';
		$resultful = sprintf($newsTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$picurl,$url);
		echo $resultful;
	}else{
		$content = '你好你好你好!!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}
}elseif($postObj->MsgType == 'image'){
		$url = 'https://api-cn.faceplusplus.com/facepp/v3/detect';
		$data = [
			'api_key'=>'AWHXLEMVlhTju6raJrlAJS5R4gPe8jX_',
			'api_secret'=>'j3etjvp-DZsz_SJpXdZNN0IOovVgO1KK',
			'image_url'=>$postObj->PicUrl,
			'return_landmark'=>'1',
			'return_attributes'=>'age,gender',
		];

		$curl = curl_init();
		//设置参数
		curl_setopt($curl,CURLOPT_URL,$url);
		curl_setopt($curl, CURLOPT_HEADER,0);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
		//发送请求信息
		$da = curl_exec($curl);
		//关闭请求资源
		curl_close($curl);
		$arr = json_decode($da,true);
		$num = count($arr['faces']);
		if($num == '0'){

			$content = '你的图片真好看!!!';
		}else{
			$content = '你的图片中有'.$num.'个人';
		}
		$msgType = 'text';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'voice'){
		$msgType = 'text';
		$content = '你的声音真好听!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'location'){
		$msgType = 'text';
		$location_x = $postObj->Location_X;
		$location_y = $postObj->Location_Y;
		$url = 'http://api.map.baidu.com/place/v2/search?query=%E5%8E%95%E6%89%80&location=' . $location_x .','. $location_y .'&scope=2&radius=2000&output=json&ak=88H9M1sNCCGGWVz7A3VZjq6xCSLx6Va5';
		$json = file_get_contents($url);
		$arr = json_decode($json,true);
		$content = '';
		foreach($arr['results'] as $k => $v){
			$content .= $v['name'] . '在' . $v['address'] . ',' . '距离你有' . $v['detail_info']['distance'] ."米,\n";
		}
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}	


?>

<?php 

echo $_GET['echostr'];
	exit;
/*//微信服务器发送get请求到我们的服务器
//token、timestamp、nonce,signature
$token = 'kaituozhe';
$timestamp = $_GET['timestamp'];
$nonce = $_GET['nonce'];
$signature = $_GET['signature'];

//将token、timestamp、nonce三个参数进行字典序排序
$arr = array($token,$timestamp,$nonce);
sort($array, SORT_STRING);

//将三个参数字符串拼接成一个字符串进行sha1加密
$arr = implode($arr);
$arr = sha1($arr);

//开发者获得加密后的字符串可与signature对比,标识该请求来源于微信
if($arr == $signature){
	$echostr =  $_GET['echostr'];
	echo $echostr;
	exit;
}*/
//--------------------------写文件(接收xml数据)---------------------------------
<?php 
	
/*echo $_GET['echostr'];
exit;*/


//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$a = $postObj->Content;
file_put_contents('./a.txt', $a)
//--------------------------回复消息---------------------------------
<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$textTpl = "<xml>
			<ToUserName><![CDATA[$fromuserName]]></ToUserName>
			<FromUserName><![CDATA[qq87080912]]></FromUserName>
			<CreateTime>12345678</CreateTime>
			<MsgType><![CDATA[text]]></MsgType>
			<Content><![CDATA[欢迎你好]]></Content>
			</xml>";
echo $textTpl;
//--------------------------关键词回复---------------------------------
<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$touserName = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$keywords = $postObj->Content;
$textTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Content><![CDATA[%s]]></Content>
			</xml>";
if($postObj->MsgType == "text" ){
	if($postObj->Content == '你好'){
		$content = '你好!!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($postObj->Content == '大帅是傻逼吗'){
		$content = '大帅确实是傻逼!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}else{
		$content = '不用问了大帅是傻逼';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}
}
//--------------------------接收不同类型的消息---------------------------------
<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$touserName = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$keywords = $postObj->Content;
$textTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Content><![CDATA[%s]]></Content>
			</xml>";
if($postObj->MsgType == "text" ){
	if($postObj->Content == '你好'){
		$content = '你好!!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($postObj->Content == '大帅是傻逼吗'){
		$content = '大帅确实是傻逼!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}else{
		$content = '不用问了大帅是傻逼';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}
}elseif($postObj->MsgType == 'image'){
		$msgType = 'text';
		$content = '你的图片真好看!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'voice'){
		$msgType = 'text';
		$content = '你的声音真美妙!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}
//--------------------------布尔教育--11--LBS厕即送---------------------------------
<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$touserName = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$keywords = $postObj->Content;
$textTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Content><![CDATA[%s]]></Content>
			</xml>";
if($postObj->MsgType == "text" ){
	if($postObj->Content == '你好'){
		$content = '你好!!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($postObj->Content == '大帅是傻逼吗'){
		$content = '大帅确实是傻逼!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}else{
		$content = '不用问了大帅是傻逼';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}
}elseif($postObj->MsgType == 'image'){
		$msgType = 'text';
		$content = '你的图片真好看!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'voice'){
		$msgType = 'text';
		$content = '你的声音真美妙!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'location'){
		$msgType = 'text';
		$location_x = $postObj->Location_X;
		$location_y = $postObj->Location_Y;
		$url = 'http://api.map.baidu.com/place/v2/search?query=%E5%8E%95%E6%89%80&location=' . $location_x .','. $location_y .'&scope=2&radius=2000&output=json&ak=ke9uqA3l6BgVgj7bCmiexVBt1FylWTL4';
		$json = file_get_contents($url);
		$arr = json_decode($json,true);
		$content = '';
		foreach($arr['results'] as $k => $v){
			$content .= $v['name'] . '在' . $v['address'] . ',' . '距离你有' . $v['detail_info']['distance'] ."米,\n";
		}
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}
//--------------------------布尔教育--11--音乐恢复---------------------------------
<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$touserName = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$keywords = $postObj->Content;
$textTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Content><![CDATA[%s]]></Content>
			</xml>";

$musicTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Music>
			<Title><![CDATA[%s]]></Title>
			<Description><![CDATA[%s]]></Description>
			<MusicUrl><![CDATA[%s]]></MusicUrl>
			<HQMusicUrl><![CDATA[%s]]></HQMusicUrl>
			</Music>
			</xml>";

if($postObj->MsgType == "text" ){
	if($postObj->Content == '你好'){
		$content = '你好!!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($postObj->Content == '大帅是傻逼吗'){
		$content = '大帅确实是傻逼!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($keywords == '音乐'){
		$msgType = 'music';
		$title = '告别气球-周杰伦';
		$des = '好听,唯美';
		$url = 'http://v.150643.com/22.mp3';
		$resultful = sprintf($musicTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$url,$url);
		echo $resultful;
	}else{
		$content = '不用问了大帅是傻逼';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}
}elseif($postObj->MsgType == 'image'){
		$msgType = 'text';
		$content = '你的图片真好看!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'voice'){
		$msgType = 'text';
		$content = '你的声音真美妙!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'location'){
		$msgType = 'text';
		$location_x = $postObj->Location_X;
		$location_y = $postObj->Location_Y;
		$url = 'http://api.map.baidu.com/place/v2/search?query=%E5%8E%95%E6%89%80&location=' . $location_x .','. $location_y .'&scope=2&radius=2000&output=json&ak=ke9uqA3l6BgVgj7bCmiexVBt1FylWTL4';
		$json = file_get_contents($url);
		$arr = json_decode($json,true);
		$content = '';
		foreach($arr['results'] as $k => $v){
			$content .= $v['name'] . '在' . $v['address'] . ',' . '距离你有' . $v['detail_info']['distance'] ."米,\n";
		}
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}
//--------------------------布尔教育--11--人脸识别Face++--------------------------------
<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$touserName = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$keywords = $postObj->Content;
$textTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Content><![CDATA[%s]]></Content>
			</xml>";

$musicTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Music>
			<Title><![CDATA[%s]]></Title>
			<Description><![CDATA[%s]]></Description>
			<MusicUrl><![CDATA[%s]]></MusicUrl>
			<HQMusicUrl><![CDATA[%s]]></HQMusicUrl>
			</Music>
			</xml>";

if($postObj->MsgType == "text" ){
	if($postObj->Content == '你好'){
		$content = '你好!!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($postObj->Content == '大帅是傻逼吗'){
		$content = '大帅确实是傻逼!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($keywords == '音乐'){
		$msgType = 'music';
		$title = '告别气球-周杰伦';
		$des = '好听,唯美';
		$url = 'http://v.150643.com/22.mp3';
		$resultful = sprintf($musicTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$url,$url);
		echo $resultful;
	}else{
		$content = '不用问了大帅是傻逼';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}
}elseif($postObj->MsgType == 'image'){
		$url = 'https://api-cn.faceplusplus.com/facepp/v3/detect';
		$data = [
			'api_key'=>'WrYx9bJJY5jjtPO2doK9mgLk1Rp2Aqi3',
			'api_secret'=>'G4qM--7D_agRXSUnNly46roH_bb-SFX6',
			'image_url'=>$postObj->PicUrl,
			'return_landmark'=>'1',
			'return_attributes'=>'age,gender',
		];

		$curl = curl_init();
		//设置参数
		curl_setopt($curl,CURLOPT_URL,$url);
		curl_setopt($curl, CURLOPT_HEADER,0);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
		//发送请求信息
		$da = curl_exec($curl);
		//关闭请求资源
		curl_close($curl);
		$arr = json_decode($da,true);
		$num = count($arr['faces']);
		if($num == '0'){

			$content = '你的图片真好看!!!';
		}else{
			$content = '你的图片中有'.$num.'个人';
		}
		$msgType = 'text';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'voice'){
		$msgType = 'text';
		$content = '你的声音真美妙!!!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'location'){
		$msgType = 'text';
		$location_x = $postObj->Location_X;
		$location_y = $postObj->Location_Y;
		$url = 'http://api.map.baidu.com/place/v2/search?query=%E5%8E%95%E6%89%80&location=' . $location_x .','. $location_y .'&scope=2&radius=2000&output=json&ak=ke9uqA3l6BgVgj7bCmiexVBt1FylWTL4';
		$json = file_get_contents($url);
		$arr = json_decode($json,true);
		$content = '';
		foreach($arr['results'] as $k => $v){
			$content .= $v['name'] . '在' . $v['address'] . ',' . '距离你有' . $v['detail_info']['distance'] ."米,\n";
		}
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}
//--------------------------布尔教育--图文++--------------------------------
<?php
	
/*echo $_GET['echostr'];
exit;*/
//接收xml数据
$postStr = $GLOBALS['HTTP_RAW_POST_DATA'];
//把xml数据转化成对象
$postObj = simplexml_load_string($postStr);
$fromuserName = $postObj->FromUserName;
$touserName = $postObj->ToUserName;
$time = time();
$msgType = $postObj->MsgType;
$keywords = $postObj->Content;
$textTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Content><![CDATA[%s]]></Content>
			</xml>";

$musicTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<Music>
			<Title><![CDATA[%s]]></Title>
			<Description><![CDATA[%s]]></Description>
			<MusicUrl><![CDATA[%s]]></MusicUrl>
			<HQMusicUrl><![CDATA[%s]]></HQMusicUrl>
			</Music>
			</xml>";

$newsTpl = "<xml>
			<ToUserName><![CDATA[%s]]></ToUserName>
			<FromUserName><![CDATA[%s]]></FromUserName>
			<CreateTime>%s</CreateTime>
			<MsgType><![CDATA[%s]]></MsgType>
			<ArticleCount>1</ArticleCount>
			<Articles>
			<item>
			<Title><![CDATA[%s]]></Title>
			<Description><![CDATA[%s]]></Description>
			<PicUrl><![CDATA[%s]]></PicUrl>
			<Url><![CDATA[%s]]></Url>
			</item>
			</Articles>
			</xml>";

if($postObj->MsgType == "text" ){
	if($postObj->Content == '你好'){
		$content = '谢谢,你也好!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($postObj->Content == '你叫什么'){
		$content = '我的名字叫:小帅!';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}elseif($keywords == '音乐'){
		$msgType = 'music';
		$title = '告别气球-周杰伦';
		$des = '好听,唯美';
		$url = 'http://v.150643.com/22.mp3';
		$resultful = sprintf($musicTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$url,$url);
		echo $resultful;
	}elseif($keywords == '图文'){
		$msgType = 'news';
		$title = '微信公开课!!!';
		$des = '好听,好学,好玩!!!';
		$picurl = 'http://v.150643.com/22.jpg';
		$url = 'http://www.baidu.com';
		$resultful = sprintf($newsTpl,$fromuserName,$touserName,$time,$msgType,$title,$des,$picurl,$url);
		echo $resultful;
	}else{
		$content = '你可以跟我说:你好,你叫什么,音乐。也可以跟我送图片、语音。';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
	}
}elseif($postObj->MsgType == 'image'){
		$url = 'https://api-cn.faceplusplus.com/facepp/v3/detect';
		$data = [
			'api_key'=>'WrYx9bJJY5jjtPO2doK9mgLk1Rp2Aqi3',
			'api_secret'=>'G4qM--7D_agRXSUnNly46roH_bb-SFX6',
			'image_url'=>$postObj->PicUrl,
			'return_landmark'=>'1',
			'return_attributes'=>'age,gender',
		];

		$curl = curl_init();
		//设置参数
		curl_setopt($curl,CURLOPT_URL,$url);
		curl_setopt($curl, CURLOPT_HEADER,0);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
		//发送请求信息
		$da = curl_exec($curl);
		//关闭请求资源
		curl_close($curl);
		$arr = json_decode($da,true);
		$num = count($arr['faces']);
		if($num == '0'){

			$content = '你的图片真好看,怎么没有人?!';
		}else{
			$content = '你的图片中有'.$num.'个人';
		}
		$msgType = 'text';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'voice'){
		$msgType = 'text';
		$content = '听到你的声音真是太好了。';
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}elseif($postObj->MsgType == 'location'){
		$msgType = 'text';
		$location_x = $postObj->Location_X;
		$location_y = $postObj->Location_Y;
		$url = 'http://api.map.baidu.com/place/v2/search?query=%E5%8E%95%E6%89%80&location=' . $location_x .','. $location_y .'&scope=2&radius=2000&output=json&ak=ke9uqA3l6BgVgj7bCmiexVBt1FylWTL4';
		$json = file_get_contents($url);
		$arr = json_decode($json,true);
		$content = '';
		foreach($arr['results'] as $k => $v){
			$content .= $v['name'] . '在' . $v['address'] . ',' . '距离你有' . $v['detail_info']['distance'] ."米,\n";
		}
		$resultful = sprintf($textTpl,$fromuserName,$touserName,$time,$msgType,$content);
		echo $resultful;
}
//--------------------------布尔教育--用户关注消息++--------------------------------

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ASP.NET微信公众号平台系统源码是一种用于构建微信公众号的框架和代码库。它提供了一系列的接口和功能,帮助开发人员快速地搭建和定制自己的微信公众号平台。 该系统源码基于ASP.NET技术开发,结合微信公众号开放平台的接口和功能进行了集成。它提供了一种便捷的方式,让开发人员可以通过编写少量的代码来实现与微信公众号的交互和功能扩展。 ASP.NET微信公众号平台系统源码具备以下特点和功能: 1. 用户管理:能够管理微信公众号的用户信息,包括用户的基本信息、关注状态、交互记录等。 2. 消息管理:能够接收和发送微信公众号的消息,包括文本消息、图片消息、语音消息、视频消息等。 3. 菜单管理:能够创建和管理微信公众号的自定义菜单,包括点击菜单、跳转链接、触发推送消息等。 4. 接口管理:能够对接微信公众号开放平台的各种接口,包括获取用户信息、发送模板消息、创建二维码等。 5. 素材管理:能够上传和管理微信公众号的素材,包括图文消息、图片、音频、视频等。 6. 数据统计:能够统计微信公众号的用户活跃度、消息互动情况、菜单点击量等数据。 ASP.NET微信公众号平台系统源码的优势在于它具有良好的扩展性和定制性,开发人员可以根据自己的需求进行二次开发和定制。同时,它也提供了一定的安全机制和权限控制,保障了用户信息和数据的安全性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值