标签:
1 /推荐使用新浪的: 2 $ch = curl_init(); 3 $url = "http://ip.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=202.102.3.141"; //测试202.102.3.141 江苏省常州市 4 curl_setopt ($ch, CURLOPT_URL, $url); 5 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 6 curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10); 7 8 $sourceInfo_sina = json_decode(curl_exec($ch)); 9 10 //淘宝(经实际使用发现,数据老旧,地区不准): 11 $ch = curl_init(); 12 $url = "http://ip.taobao.com/service/getIpInfo.php?ip=202.102.3.141"; //测试202.102.3.141 江苏省常州市 13 curl_setopt ($ch, CURLOPT_URL, $url); 14 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 15 curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10); 16 17 $sourceInfo_taobao = json_decode(curl_exec($ch));
标签:
原文地址:http://www.cnblogs.com/CHEUNGKAMING/p/4262009.html