微信域名检测 腾讯微信域名检测的机制原理以及实现方式

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

  1.  
    $url = "http://api.xxxx.com";
  2.  
    $params = array(
  3.  
    'appkey' =>'appkey',//您申请的APPKEY
  4.  
    'url' =>'www.monkeyapi.com',//您需要检测的域名
  5.  
    );
  6.  
     
  7.  
    $paramstring = http_build_query($params);
  8.  
    $content = monkeyCurl($url, $paramstring);
  9.  
    $result = json_decode($content, true);
  10.  
    if($result) {
  11.  
    var_dump($result);
  12.  
    } else {
  13.  
    //请求异常
  14.  
    }
  15.  
     
  16.  
    /**
  17.  
    * 请求接口返回内容
  18.  
    * @param string $url [请求的URL地址]
  19.  
    * @param string $params [请求的参数]
  20.  
    * @param int $ipost [是否采用POST形式]
  21.  
    * @return string
  22.  
    */
  23.  
    function monkeyCurl($url, $params = false, $ispost = 0)
  24.  
    {
  25.  
    $httpInfo = array();
  26.  
    $ch = curl_init();
  27.  
     
  28.  
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  29.  
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
  30.  
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  31.  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  32.  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  33.  
    if ($ispost) {
  34.  
    curl_setopt($ch, CURLOPT_POST, true);
  35.  
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
  36.  
    curl_setopt($ch, CURLOPT_URL, $url);
  37.  
    } else {
  38.  
    if ($params) {
  39.  
    curl_setopt($ch, CURLOPT_URL, $url. '?'.$params);
  40.  
    } else {
  41.  
    curl_setopt($ch, CURLOPT_URL, $url);
  42.  
    }
  43.  
    }
  44.  
     
  45.  
    $response = curl_exec($ch);
  46.  
    if ($response === FALSE) {
  47.  
    //echo "cURL Error: " . curl_error($ch);
  48.  
    return false;
  49.  
    }
  50.  
     
  51.  
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  52.  
    $httpInfo = array_merge($httpInfo, curl_getinfo($ch));
  53.  
    curl_close($ch);
  54.  
    return $response;
  55.  
    }
  56.  

猜你喜欢

转载自www.cnblogs.com/qvli1/p/10268523.html
今日推荐