微信域名检测API接口实现方法及原理

微信域名检测API接口是腾讯对外公布的微信域名状态查询接口,可实时查询域名在微信中的状态,如果状态异常则返回结果提示“域名被封”,如果未有异常则返回结果提示“域名正常”。

域名有如下几种状态:

  1. 域名能正常访问(未被微信拦截)

  2. 域名被微信拦截

  3. 非微信官方网页,继续访问将转换成手机预览模式(在公众号后台把域名添加到业务域名一般能解决这个问题)

  4. 据用户投诉及腾讯安全网址安全中心检测,该网页包含恶意欺诈内容,为维护绿色上网环境,已停止访问

  5. 网页包含诱导分享、关注等诱导行为内容,被多人投诉,为维护绿色上网环境,已停止访问

源码

$url = “http://api.monkeyapi.com”;
$params = array(
‘appkey’ =>‘appkey’,//您申请的APPKEY
‘url’ =>‘www.monkeyapi.com’,//需要查询的网站
);

paramstring=httpbuildquery(paramstring = http_build_query(paramstring=httpbuildquery(params);
content=Curl(content = Curl(content=Curl(url, $paramstring);
result=jsondecode(result = json_decode(result=jsondecode(content, true);
if(KaTeX parse error: Expected '}', got 'EOF' at end of input: …{ var_dump(result);
}else {
//请求异常
}

// 想要详细了解可以+V mkapi002

/**
* 请求接口返回内容
* @param string $url [请求的URL地址]
* @param string $params [请求的参数]
* @param int ipost[是否采用POST形式]∗@returnstring∗/functionCurl(ipost [是否采用POST形式] * @return string */ function Curl(ipost[POST]@returnstring/functionCurl(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;

}

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值