Micro-channel detection domain interfaces (including PHP, Python call presentation step)

Micro Domain Name Monitoring Interface Tencent official release api interfaces, call detecting the interface to return the domain name living conditions in the micro letter, if it was blocked return results suggest that the "domain name blocked", if not blocked and the result is returned prompt "Domain normal . "

 

Interface detecting micro Domain Name (official)

http://www.xiaocaoff.cn/weixin/check-api.php?url=http://www.baidu.com

 

Interface instructions

1, online use

Api interface address will be replaced by the "http://www.baidu.com" domain name you need to detect, and then copy and paste the address to open the browser, go to return results.

2, access interface

If that line is cumbersome to use, or require real-time query, the interface to access the server code, the return parameter, a state can be detected in real time in the micro domain letter.

 

PHP call demo

 1 <?php
 2 // 需要检测的地址或域名
 3 
 4 $reqUrl = "http://www.baidu.com";
 5 
 6 $url = sprintf("http://www.xiaocaoff.cn/weixin/check-api.php?url=http://www.baidu.com",$reqUrl);
 7 
 8 $ch = curl_init($url);
 9 
10 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
11 
12 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
13 
14 $responseBody= The curl_exec ( $ CH );
 15  
16  $ responseArr = of json_decode ( $ the responseBody , to true );
 . 17  
18 is  IF (! Json_last_error () = JSON_ERROR_NONE) {
 . 19  
20 is      echo "the JSON resolved interfaces results error \ n-" ;
 21 is  
22 is      return ;
 23 is  
24  }
 25  
26 is  IF ( isset ( $ responseArr [ 'code']) && $ responseArr [ 'code'] == 0 ) {
 27  
28      // Interface returns the correct
 29  
30     // $ responseArr [ 'data'] [ 'status'] ranges: OK, blocked
 31 is  
32      // OK indicates normal, blocked represents capped 
33 is  
34 is      the printf ( "address test (% s) of state:% S \ n-", $ reqURL , $ responseArr [ 'Data'] [ 'Status' ]);
 35  
36 } the else {
 37 [  
38 is      the printf (" Interface exception:% S \ n-", var_export ( $ responseArr , to true ));
 39  
40 }

 

Python call demo

. 1  DEF main ():
 2  
. 3      URL = " http://www.xiaocaoff.cn/weixin/check-api.php " 
. 4  
. 5      the params = {
 . 6  
. 7          " req_url " : " http://www.baidu.com " , # necessary to detect addresses or domain names 
. 8  
. 9      }
 10  
. 11      the params = urlencode (the params)
 12 is  
13 is      F = urllib.urlopen ( " % S? S% " % (URL, the params))
 14  
15   
16  
. 17      Content = f.read()
18 
19     res = json.loads(content)
20 
21     if res:
22 
23         code = res["code"]
24 
25         if code == 0:
26 
27             #成功请求
28 
29             print res["result"]
30 
31         else:
32 
33             print "%s: %s" % (res["code"],res["msg"])
34 
35     else:
36 
37         print "request api error"
38 
39  
40 
41 if __name__ == '__main__':
42 
43     main()

 

Precautions:

1, when you call api interface simply "http://www.baidu.com" domain name to replace the need for testing.

2, API interface supports domain names with parameters, when the & symbol appears in the domain name, use 26% instead of (or use the url encoding format), as this may result in the return inaccurate results.

3, the domain name must be based on http (s): // at the beginning, this may result in failure or can not return queries and other issues.

4, the above-mentioned API interface, I use half a year, has been relatively stable, you can try, feel good about remember collection, to avoid loss can not be found.

 

common problem:

1, Why the interface returns a result inconsistent with the actual?

A: The special character domain names carry no coding, resulting parameter does not take effect; or because the domain name is not to be detected with http (s): // at the beginning.

2, the interface does not return results, what is the situation?

A: Sometimes there is a delay return data interfaces, the timeout will return fails, the return parameter that is empty; or call the wrong way, details can be found above presentation interface calls.

3, access interface, the fastest detection times per second?

A: The interface supports up to 6 times / second without interruption detection result is returned within 2 seconds.

Guess you like

Origin www.cnblogs.com/ctsn/p/12002854.html