返回的是json 如果200则域名正常 201则域名报毒 -1则未知的异常
只有域名错误或未输入情况下则未知的异常
<php
/*
*@PageName:微信域名报毒检查
*@Author:wlkjyy
*@Date:2019/9/18
*@Return [bool] result
*@Return [int] code
*@Return [string] msg
*/
$time = time();//需要传输时间戳
$domain = $_GET["domain"];
$url = 'https://cgi.urlsec.qq.com/index.php?m=check&a=check&callback=jQuery172003766602530889873_'.$time.'&url=http://'.$domain.'&_='.$time;//请求地址
//通过抓包,获取到腾讯的域名报毒查询地址
$referer = 'https://guanjia.qq.com/online_server/result.html?url=http://'.$domain.'&=';//需要模拟来源
function get_curl($url,$post=0,$referer=0,$cookie=0,$header=0,$ua=0,$nobaody=0){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:*/*";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
if($post){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if($header){
curl_setopt($ch, CURLOPT_HEADER, TRUE);
}
if($cookie){
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if($referer){
if($referer==1){
curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
}else{
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
}
if($ua){
curl_setopt($ch, CURLOPT_USERAGENT,$ua);
}else{
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Linux; U; Android 4.4.1; zh-cn; R815T Build/JOP40D) AppleWebKit/533.1 (KHTML, like Gecko)Version/4.0 MQQBrowser/4.5 Mobile Safari/533.1');
}
if($nobaody){
curl_setopt($ch, CURLOPT_NOBODY,1);
}
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}//准备函数
$Data = get_curl($url,0,$referer);
$preg = '/,"whitetype":(.*?),/is';
preg_match_all($preg,$Data,$key);
$status = $key[1][0];//得出状态
function json($result,$code,$msg)
{
return '{"result":'.$result.',"code":'.$code.',"msg":"'.$msg.'"}';
}
header('Content-type:application/json;charset=utf-8');
switch($status)
{
case '2'://域名报毒
exit(json(true,201,"域名异常"));
break;
case '1':
exit(json(true,200,"域名正常"));
break;
default:
exit(json(false,-1,"未知的异常"));
}
?>
留言咨询