PHP微信公众号自动回复开发案列之苹果iPhone IMEI信息查询

2018-07-20    来源:open-open

容器云强势上线!快速搭建集群,上万Linux镜像随意使用
<?php
error_reporting(0); 
header("content-Type: text/html; charset=utf-8");

$title = "某某苹果查询系统"; 	//<----【请修改】'设置查询标题,相信你懂的;
//代码仅供学习,不要用于非法目的

//以下无需修改;
 $echoStr = $_GET["echostr"];
if($echoStr){
 exit($echoStr);
}

function chaimei($imei){
//////////////////////////////////////////////////
$urlimei = 'http://iunlocker.net/check_imei.php';	//POST地址
$referer = 'http://iunlocker.net/check_imei.php';	//来源地址
///////////////////////////////////////////////////
$ip = rand(1,254).'.'.rand(1,254).'.'.rand(1,254).'.'.rand(1,254);  //随机IP

$html1 = ccurl($urlimei,"imei=".$imei,$referer,$ip);
$regtest = "/<table[^>]*>(.*?)<\/table>/is";
$html1 = str_replace(array("\r\n", "\r", "\n", "\t", "&nbsp;")," ",$html1);
preg_match_all($regtest , $html1 , $matches);
//var_dump($matches[1][0]);
$text = $matches[1][0];
$text = str_replace('</tr>', '</tr>[{-换行-}]', $text); 
$text = str_replace('<b>', ':<b>', $text); 
$text = strip_tags($text);
$text = preg_replace("/[\s]+/is"," ",$text);
$text = str_replace('[{-换行-}]', "\n", $text); 
$text = str_replace(': :', ':', $text); 
if($text){
return $text;
}else{
return "查询失败!检查IMEI是否正确!";
}
}

function ccurl($url , $post = '' , $referer = '' , $ip = '8.8.8.8') {
	$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_CONNECTTIMEOUT, 600);
	curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);	
	curl_setopt($curl, CURLOPT_HTTPHEADER, array("Accept-Language: ch-CN","X-FORWARDED-FOR:$ip","CLIENT-IP:$ip"));
	curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
	if ($referer) {
		curl_setopt($curl, CURLOPT_REFERER, $referer);
	} else {
		curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
	}
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
	if (!empty($post)) {
		curl_setopt($curl, CURLOPT_POST, 1);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
	}
		curl_setopt($curl, CURLOPT_COOKIE, '');

	$nres = curl_exec($curl);
	curl_close($curl);
	if ($nres) {
		return $nres;
	}
}

 $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //获取POST数据
 //用SimpleXML解析POST过来的XML数据
 $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
 $fromUsername = $postObj->FromUserName; //获取发送方帐号(OpenID)
 $toUsername = $postObj->ToUserName; //获取接收方账号
 $msgtype = trim($postObj->MsgType); //获取消息的类型
 $msgtype = strtolower($msgtype);
switch ($msgtype){
 case "image":
 $contentStr = "这是传说中的艳照吧,客服美眉我可是女的,不感兴趣哦!\r\n ";
 break;
 case "video":
 $contentStr = "莫非这就是传说中的A片?姐姐我没空看哦!有话直说吧! \r\n ";
 break;
 case "location":
 $keywords = trim($postObj->Label); 
 $keyword = iconv('UTF-8', 'GB2312', $keywords);
 $contentStr = "你的位置信息是:"; 
 $contentStr .= "\r\n【经度】:".$postObj->Location_X; 
 $contentStr .= "\r\n【纬度】:".$postObj->Location_Y; 
 $contentStr .= "\r\n【精度】:".$postObj->Scale; 
 $contentStr .= "\r\n【位置】:".$keyword; 
 $contentStr .= "\r\n 哎呀喂,别告诉我你的位置哇!我又不会来敲门!!";
 break;
 case "voice":
 $contentStr = "你的声音很甜美,只是客服美眉暂还没学会跟你语音对讲!\r\n ";
 break;
 case "music":
 $contentStr = "哇,很好听的音乐!不过姐很忙没空听,有话直说吧!\r\n ";
 break;
 case "news":
 $contentStr = "两个凡是:凡是网址都是病毒,凡是新闻我都不会去关注!\r\n ";
 break;
 case "link":
 $contentStr = "两个凡是:凡是网址都是病毒,凡是网址我都不会去打开!\r\n ";
 break;
 case "event":
 $Events = trim($postObj->Event); 
 $Events = strtolower($Events);
 if($Events=="unsubscribe"){
 $contentStr = "呜呜呜,干嘛取消关注我们!难道我不漂亮么?";
 }elseif ($Events=="subscribe") {
 $contentStr = "非常感谢你关注【".$title."】 微信自动查询机器人!";
 }elseif ($Events=="click") {
 $contentStr = "你刚才点了底部菜单!";
 }else{
 $contentStr = "感谢关注我们!\r\n ";
 }
 break;
 case "text":
 $keyword = trim($postObj->Content); 
preg_match_all('/[0-9]{14,15}/', $keyword, $temp);
$time = time(); //获取当前时间戳
 $msgType = "text"; //消息类型
 $textTpl1 = "<xml>
 <ToUserName><![CDATA[%s]]></ToUserName>
 <FromUserName><![CDATA[%s]]></FromUserName>
 <CreateTime>%s</CreateTime>
 <MsgType><![CDATA[%s]]></MsgType>
 <Content><![CDATA[";

$resultStr = sprintf($textTpl1, $fromUsername, $toUsername, $time, $msgType, "");
 echo iconv('GB2312', 'UTF-8', $resultStr); 
foreach ($temp[0] as $v)
{
	$i++;
 $imei = $v;
 $imeis .= $v;
 echo chaimei("".$v."") . "\r\n\r\n";
 //$contentStr .= $imea . "\r\n\r\n"; 
}

if(!$imeis){
 //$contentStrs = "没有识别到正确的15位苹果手机串号\r\n 请发我15位苹果手机串号查询!";
 //echo iconv('GB2312', 'UTF-8', $resultStrs); 
}
 echo iconv('GB2312', 'UTF-8', " 请发我15位苹果手机串号查询!"); 
 $textTpl2 = "]]></Content>
 <FuncFlag>0</FuncFlag>
 </xml>";

$resultStr = sprintf($textTpl2, $fromUsername, $toUsername, $time, $msgType, "");
 echo iconv('GB2312', 'UTF-8', $resultStr); 

exit();
 break;
 default:
 $keyword = $msgtype; 
 $contentStr = "客服美眉暂时无法识别你【$msgtype】格式的信息哦!\r\n ";
 break;
}

$time = time(); //获取当前时间戳

 //返回消息模板
 $textTpl = "<xml>
 <ToUserName><![CDATA[%s]]></ToUserName>
 <FromUserName><![CDATA[%s]]></FromUserName>
 <CreateTime>%s</CreateTime>
 <MsgType><![CDATA[%s]]></MsgType>
 <Content><![CDATA[%s]]></Content>
 <FuncFlag>0</FuncFlag>
 </xml>";
 $contentStr .= "\r\n 请发我15位苹果手机串号查询!";
 $msgType = "text"; //消息类型
 //格式化消息模板
 $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
 echo iconv('GB2312', 'UTF-8', $resultStr); 

?>

标签: ssl 代码

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。

上一篇:Java创建二叉树并遍历的代码

下一篇:Java实现多文件压缩和解压缩代码