最近在网上看到很多网友在问微信域名拦截检测API接口。有的是想找一个稳定靠谱的服务商,有的是刚接触这方面的业务想通过程序来代替之前的人工检测,更有甚者想具体了解微信域名检测API接口的原理,当然这部分人群大多数是技术人员或者是喜欢研究的。不管你是出于什么目的,作为一个研究接口服务多年的人来说这个接口的原理是非常简单的,而且产品基本上也很成熟。如果不是想深入接口行业而只是用这个工具,建议直接购买服务即可,着重考虑营销方面可能更有必要。今天在这里分享一段代码供大家参考,如有的方

-
$url =
“http://api.xxxx.com”; -
$params =
array( -
‘appkey‘ =>‘appkey‘,//您申请的APPKEY
-
‘url‘ =>‘www.monkeyapi.com‘,//您需要检测的域名
-
);
-
-
$paramstring = http_build_query($params);
-
$content = monkeyCurl($url, $paramstring);
-
$result = json_decode($content,
true); -
if($result) {
-
var_dump($result);
-
}
else { -
//请求异常
-
}
-
-
/**
-
* 请求接口返回内容
-
* @param string $url [请求的URL地址]
-
* @param string $params [请求的参数]
-
* @param int $ipost [是否采用POST形式]
-
* @return string
-
*/
-
function monkeyCurl($url, $params = false, $ispost = 0)
-
{
-
$httpInfo =
array(); -
$ch = curl_init();
-
-
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
-
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,
60); -
curl_setopt($ch, CURLOPT_TIMEOUT,
60); -
curl_setopt($ch, CURLOPT_RETURNTRANSFER,
true); -
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,
true); -
if ($ispost) {
-
curl_setopt($ch, CURLOPT_POST,
true); -
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
-
curl_setopt($ch, CURLOPT_URL, $url);
-
}
else { -
if ($params) {
-
curl_setopt($ch, CURLOPT_URL, $url.
‘?‘.$params); -
}
else { -
curl_setopt($ch, CURLOPT_URL, $url);
-
}
-
}
-
-
$response = curl_exec($ch);
-
if ($response === FALSE) {
-
//echo “cURL Error: ” . curl_error($ch);
-
return false;
-
}
-
-
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
-
$httpInfo = array_merge($httpInfo, curl_getinfo($ch));
-
curl_close($ch);
-
return $response;
-
}
-