API code for phpcurl to obtain all information of a specified IP address
This article describes how to use the curl function in php to obtain the API code of all information under the specified IP address. For more information, see. Share The api code that uses curl to retrieve all information under the specified IP address. For curl-related content, refer to the following articles: php curl simple example of uploading files php curl post simple example php curl application instance analysis php curl usage instance code php use curl to determine whether a remote file exists php use curl to forge IP source php curl learning summary first charging, then read the following code. The code is as follows:
True,); curl_setopt_array ($ ch, $ options); $ res = curl_exec ($ ch); curl_close ($ ch); if ($ xml = simplexml_load_string ($ res )) {$ dt = array (); foreach ($ xml-> Location-> children () as $ key => $ item) {$ dt [$ key] = strtolower ($ item);} return $ dt;} else {return false ;}$ current_Ip_Info = getIpInfo ('61. 164.140.55'); var_dump ($ current_Ip_Info);/* returned content: array (13) {["Ip"] => string (13) "61.164.140.55" ["Status"] => String (2) "OK" ["CountryCode"] => string (2) "cn" ["CountryName"] => string (5) "china" ["RegionCode"] => string (2) "02" ["RegionName"] => string (8) "zhejiang" ["City"] => string (5) "ruian" ["ZipPostalCode"] => string (0) "" ["Latitude"] => string (7) "27.7814" ["longpolling"] => string (7) & quot; 120.628 & quot; [& quot; TimezoneName & quot;] = & quot; string (14) & quot; asia/chongqing & quot; [& quot; Gmtoffset & quot;] = & quot; string (5) "28800" ["Isdst"] => string (1) "0 "}*/? > |