淘宝IP地址查询接口
Clas s TaobaoIPQuery2{private static $_requestURL=‘http://ip.taobao.c om/s ervic e/getIpInfo.php’ ;public static function getIPInfo($ip){
$long=ip2long($ip);if($long===0){throw new Exc eption(‘IP address error’, 5);
$ip=long2 ip($long);
$IPInfo=self::queryIPInfo($ip);return self::p arseJSON($IPInfo);private static function queryIPInfo($ip){
$query=http_build_query(array(‘ip’=$ip));
$ch=curl_init();
$options=array(
CURLOPT_URL=sprintf(‘%s?%s’, s elf: :$_requestURL, $query),CURLOPT_RET URNTRANSF ER=true,
CUR LOP T_AUT OR EF ER ER=fals e,
CURLOP T_F OLLO WLO C AT I ON=fals e,
CURLOP T_HE AD ER=fals e,
CURLOP T_T IMEO UT=3.0,curl_setopt_array($ch,$options);
$c ontent=curl_exec($ch);curl_close($ch);
r eturn$c ontent;private static function parseJSON($json){
$O=json_dec ode($json, true);if(fals e===is_null($O)){r eturn$O;if(vers ion_c ompare(PHP_VERSION, ‘5.3.0’, ‘=‘)) {
$errorCode=js on_last_error();if(is s et(s elf::$_JSONPars eError[$errorCode])){throw new Exception(self: :$_JSONParseError[$errorCode],5);throw new Exception(‘JSON parse error’, 5);private static $_JSONParseError=array(
JSON_ERROR_NONE=‘No error has occurred’,
JSON_ERROR_DEPT H=‘The maximum stack depth has been exceeded’ ,
JSON_ERROR_CTRL_CHAR=‘Control character error,possibly incorrectly encoded’,JSON_ERROR_STATE_MISMATCH=‘Invalid or malformed JSON’,
J S ON_ERROR_SYNTAX=‘Syntax error’ ,
JSON_ERROR_UTF8=‘Malformed UTF-8 characters,possibly incorrectly encoded’,}
TaobaoIPQuery2.Clas s.php~2KB
?p hp
Clas s TaobaoIPQuery2{private static $_requestURL=‘http://ip.taobao.c om/s ervic e/getIpInfo.php’ ;
public static function getIPInfo($ip){
$long=ip2long($ip);if($long===0){throw new Exception(‘IP address error’, 5);
$ip=long2 ip($long);
$IPInfo=self::queryIPInfo($ip);return self::p arseJSON($IPInfo);private static function queryIPInfo($ip){
$query=http_build_query(array(‘ip’=$ip));
$ch=curl_init();
$options=array(
CURLOPT_URL=sprintf(‘%s?%s’, s elf: :$_requestURL, $query),CURLOPT_RET URNTRANSF ER=true,
CUR LOP T_AUT OR EF ER ER=fals e,
CURLOP T_F OLLO WLO C AT I ON=fals e,
CURLOP T_HE AD ER=fals e,
CURLOP T_T IMEO UT=3.0,curl_setopt_array($ch,$options);
$c ontent=curl_exec($ch);curl_close($ch);r eturn$c ontent;private static function parseJSON($json){
$O=json_dec ode($json, true);if(fals e===is_null($O)){r eturn$O;if(vers ion_c ompare(PHP_VERSION, ‘5.3.0’, ‘=‘)) {
$errorCode=js on_last_error();if(is set(self::$_JSONParseError[$errorCode])){throw new Exception(self: :$_JSONParseError[$errorCode],5);throw new Exception(‘JSON parse error’, 5);private static $_JSONParseError=array(
JSON_ERROR_NONE=‘No error has occurred’,
JSON_ERROR_DEPT H=‘The maximum stack depth has been exceeded’ ,
JSON_ERROR_CTRL_CHAR=‘Control character error,possibly incorrectly encoded’,JSON_ERROR_STATE_MISMATCH=‘Invalid or malformed JSON’,
J S ON_ERROR_SYNTAX=‘Syntax error’ ,
JSON_ERROR_UTF8=‘Malformed UTF-8 characters,possibly incorrectly encoded’,}
古德云(goodkvm)怎么样?古德云是一家成立于2020年的商家,原名(锤子云),古德云主要出售VPS服务器、独立服务器。古德云主打产品是香港cn2弹性云及美西cn2云服务器,采用的是kvm虚拟化构架,硬盘Raid10。目前,古德云香港沙田cn2机房及美国五星级机房云服务器,2核2G,40G系统盘+50G数据盘,仅35元/月起,性价比较高,可以入手!点击进入:古德云goodkvm官方网站地址古德...
快快CDN主营业务为海外服务器无须备案,高防CDN,防劫持CDN,香港服务器,美国服务器,加速CDN,是一家综合性的主机服务商。美国高防服务器,1800DDOS防御,单机1800G DDOS防御,大陆直链 cn2线路,线路友好。快快CDN全球安全防护平台是一款集 DDOS 清洗、CC 指纹识别、WAF 防护为一体的外加全球加速的超强安全加速网络,为您的各类型业务保驾护航加速前进!价格都非常给力,需...
bluehost怎么样?bluehost推出新一代VPS美国云主机!前几天,BlueHost也推出了对应的周年庆活动,全场海外虚拟主机月付2.95美元起,年付送免费的域名和SSL证书,通过活动进入BlueHost中文官网,购买虚拟主机、云虚拟主机和独立服务器参与限时促销。今天,云服务器网(yuntue.com)小编给大家介绍的是新一代VPS美国云主机,美国SSD云主机,2核2G/20GB空间,独立...