久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      怎么使用PHP查詢IP地址歸屬地

      PHP查詢IP地址歸屬地的步驟:1、開通IP地址歸屬地接口服務(wù),獲取接口請(qǐng)求Key;2、調(diào)用接口API發(fā)出請(qǐng)求,根據(jù)查詢的IP地址,查詢?cè)揑P所屬的區(qū)域;3、自定義juheHttpRequest()獲取請(qǐng)求接口返回的內(nèi)容即可。

      怎么使用PHP查詢IP地址歸屬地

      php入門到就業(yè)線上直播課:進(jìn)入學(xué)習(xí)
      Apipost = Postman + Swagger + Mock + Jmeter 超好用的API調(diào)試工具:點(diǎn)擊使用

      怎么查詢IP地址歸屬地?下面本篇文章就來(lái)給大家介紹一下使用PHP查詢IP地址歸屬地的方法。

      PHP查詢IP地址歸屬地的步驟:

      1、開通接口

      P地址歸屬地接口服務(wù)使用的聚合數(shù)據(jù)提供的免費(fèi)接口,可以通過(guò) https://www.juhe.cn/docs/api/id/1?s=cpphpcn 注冊(cè)及開通。

      2、根據(jù)查詢的IP地址,查詢?cè)揑P所屬的區(qū)域

      // 接口請(qǐng)求Key,可以通過(guò)https://www.juhe.cn/docs/api/id/1免費(fèi)申請(qǐng)開通 $appkey = "*********************";  //根據(jù)查詢的IP地址,查詢?cè)揑P所屬的區(qū)域 $url = "http://apis.juhe.cn/ip/ipNew"; $params = [     "ip" => "112.112.11.11",//需要查詢的IP地址或域名     "key" => $appkey,//應(yīng)用APPKEY(應(yīng)用詳細(xì)頁(yè)查詢) ]; $paramstring = http_build_query($params); $content = juheHttpRequest($url, $paramstring, 1); $result = json_decode($content, true); if ($result) {     if ($result['error_code'] == 0) {         echo "國(guó)家:{$result['result']['Country']}" . PHP_EOL;         echo "省份:{$result['result']['Province']}" . PHP_EOL;         echo "城市:{$result['result']['City']}" . PHP_EOL;         echo "運(yùn)營(yíng)商:{$result['result']['Isp']}" . PHP_EOL;     } else {         echo "{$result['error_code']}:{$result['reason']}" . PHP_EOL;     } } else {     echo "請(qǐng)求失敗"; }
      登錄后復(fù)制

      3、請(qǐng)求接口返回內(nèi)容

      /**  * 請(qǐng)求接口返回內(nèi)容  * @param string $url [請(qǐng)求的URL地址]  * @param string $params [請(qǐng)求的參數(shù)]  * @param int $ipost [是否采用POST形式]  * @return  string  */ function juheHttpRequest($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_USERAGENT, 'JuheData');     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);     curl_setopt($ch, CURLOPT_TIMEOUT, 5);     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; }
      登錄后復(fù)制

      推薦學(xué)習(xí):《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)