淘宝淘宝ip地址查询接口

查询ip地址  时间:2020-12-31  阅读:()

淘宝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’,}

小欢互联19元/月起, 即日起至10月底 美国CERA 促销活动 美国/香港八折

小欢互联成立于2019年10月,主打海外高性价比云服务器、CDN和虚拟主机服务。近期上线了自营美国CERA机房高速VPS,进行促销活动,为客户奉上美国/香港八折优惠码:Xxc1mtLB优惠码适用于美国CERA一区/二区以及香港一区/二区优惠时间:即日起至10月底优惠码可无限次使用,且续费同价!官网:https://idc.xh-ws.com购买地址:美国CERA一区:https://idc.xh-...

半月湾($59.99/年),升级带宽至200M起步 三网CN2 GIA线路

在前面的文章中就有介绍到半月湾Half Moon Bay Cloud服务商有提供洛杉矶DC5数据中心云服务器,这个堪比我们可能熟悉的某服务商,如果我们有用过的话会发现这个服务商的价格比较贵,而且一直缺货。这里,于是半月湾服务商看到机会来了,于是有新增同机房的CN2 GIA优化线路。在之前的文章中介绍到Half Moon Bay Cloud DC5机房且进行过测评。这次的变化是从原来基础的年付49....

ZJI韩国BGP+CN2服务器,440元起

ZJI又上新了!商家是原Wordpress圈知名主机商:维翔主机,成立于2011年,2018年9月启用新域名ZJI,提供中国香港、台湾、日本、美国独立服务器(自营/数据中心直营)租用及VDS、虚拟主机空间、域名注册等业务。本次商家新上韩国BGP+CN2线路服务器,国内三网访问速度优秀,适用8折优惠码,优惠后韩国服务器最低每月440元起。韩国一型CPU:Intel 2×E5-2620 十二核二十四线...

查询ip地址为你推荐
独立ip主机独立IP主机和CDN主机的详细区别?美国主机空间买空间网的美国主机咋样?linux主机Linux中,用户名和主机名有什么区别?域名代理现在做域名代理好做吗?还能赚到钱吗?vpsvps什么意思vps主机vps主机好吗?是不是垃圾?免费国外空间哪里的国外免费空间好?ip代理地址ip代理有什么用?有图片..免备案虚拟空间免备案的虚拟主机空间,买了以后会强制备案不?php虚拟空间怎样修改php虚拟空间单个文件上传大小限制
虚拟主机服务商 息壤主机 bluehost 128m内存 gg广告 河南m值兑换 北京双线 免费防火墙 速度云 腾讯实名认证中心 t云 域名与空间 个人免费邮箱 lamp兄弟连 测速电信 广东主机托管 服务器防御 网站防护 重庆联通服务器托管 xshell5注册码 更多