background Recently have a project in hand need to detect whether the domain name in WeChat can open, if be WeChat interception, requires into the next phase of the operation, so you need to determine the domain name of state, but WeChat official did not provide related query methods, finally found the interface address on the Internet, to share with a friend in need.

Common reasons why a domain name is blocked Are as follows:

1, the purchase of the domain name has a black history, has entered the small black house, this kind of risk list is the key detection object.

2, QQ and wechat are two completely different detection mechanisms, often appear to be blocked on the other side of the fine!

3, the site traffic is too large, Tencent for the traffic of the site is also a key detection object!

4. Induced forwarding activities, even legal marketing, will also be blocked;

5. Any text, title and picture with a little illegal information will be banned if captured by the system

6, artificial report, this also has a certain proportion

7, some seal links do not seal domain name, because it is the third-party platform of Tencent cooperation, JINGdong, Pinduoduo, Zan and so on

8, the server IP is a very important detection.

9, for obvious features or high reuse of illegal pictures, the system is able to identify!

API API Name Description API Address Api.yemao. VIP /v2/wechat\_… Return format JSON Request Method GET Request example api.yemao. VIP /v2/wechat\_… Key&url =www.qq.com Interface Remarks If you are in the login state, the App Key shown in the request example is your real App Key. You do not need to query the App Key in my APPKEY

Request Parameter Description Parameter Mandatory Type Description APP_key is the App Key of user String, which can be queried in my APPKEY. The URL used for API calls is the URL or domain name that String needs to detect, for example, www.qq.com/ or www.qq.com

Parameter Description Mandatory Parameter Type Description Code INTEGER Specifies the status code. 0 indicates normal and non-0 indicates an error. MSG String Indicates a message. Err_code INTEGER Specifies the reason why the domain name is blocked. The value can be 0 (normal), 30001 (the page is transcoded), 30002 (the page has been stopped), or 30998 (To view the domain name, Data. Err_msg string Error description Data. Sub_err_msg string Detailed error description

JSON return example

{"code": 10001, "MSG ":" Interface call frequency is too fast ", "data": []} // The server processing request exception {"code": 10004, "MSG ":" system internal error, please try again ", "data": []} / / request is successful and the normal domain name {" code ": 0," MSG ":" OK ", "data" : {" status ":" OK ", "err_code" : 0, "err_msg" : ""," sub_err_msg ": {"code": 0, "MSG ": "OK", "data": {"status": "blocked", "err_code": {"status": "blocked", "err_code": 30002, "err_msg": "stopped accessing this page ", "sub_err_msg":" this page contains infringing content "}} // The request was successful but the domain name was blocked // Blocked reason: the page was transcoded - non-wechat official page {"code": 0, "MSG ": "OK", "data" : {" status ":" blocked ", "err_code:" 30001, "err_msg" : "page is transcoding," "sub_err_msg" : {"code": 0, "MSG ": "OK", "data": {"status": "blocked", "err_code": {"status": "blocked", "err_code": 30998, "err_msg": "If you want to browse, please long press the url copy and use the browser to access ", "sub_err_msg": ""}}Copy the code

Example code Python

# -*- coding: utf-8 -*- import json, urllib from urllib import urlencode def main(): # Your App Key, In my APPKEY can inquire to apiToken = "* * * * * * * * * * * * * * * * * * * * *" url = "https://api.yemao.vip/v2/wechat_url_check" params = {" url ": "www.qq.com", # address or domain name to check "app_key" : apiToken, } params = urlencode(params) f = urllib.urlopen("%s?%s" % (url, params)) content = f.read() res = json.loads(content) if res: code = res["code"] if code == 0: # success request print res (" result ") else: print "% s: % s" % (res (" code "), the res (" MSG ")) else: print "request api error" if __name__ == '__main__': main()Copy the code

PHP

<? PHP/cat - VIP * @ * * * @ the author copyright 2020 * * @ see http://yemao.vip/open/weixin_jiance/try {/ / your App Key, In my APPKEY can inquire to $apiToken = "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"; $reqUrl = "www.qq.com"; $url = sprintf("https://api.yemao.vip/v2/wechat_url_check? app_key=%s&url=%s", $apiToken, $reqUrl); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); // Disable cURL to verify peer's certificate. This configuration is not recommended in production environments. It is recommended to download the latest certificate / / https://curl.haxx.se/docs/caextract.html and open the PHP. Ini added: curl.cainfo=/path/to/cacert.pem curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $responseBody = curl_exec($ch); if ($responseBody === false) { printf("Curl error: %s\n", curl_error($ch)); return; } $responseArr = json_decode($responseBody, true); if (json_last_error() ! = JSON_ERROR_NONE) {printf("JSON: error: %s\n", json_last_error_msg()); return; If ($responseArr['code']) && $responseArr['code'] == 0) {$responseArr['data']['status'] == 0; Ok and blocked // OK: the virtual drive is normal. Printf ($reqUrl, $responseArr['data']['status']); } else {printf(" error: %s\n", var_export($responseArr, true)); }} catch(Exception $e) {printf(" error: %s\n", $e->getMessage()); }Copy the code