淘宝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’,}
RAKsmart发布了新年钜惠活动,即日起到2月28日,商家每天推出限量服务器秒杀,美国服务器每月30美元起,新上了韩国服务器、GPU服务器、香港/日本/美国常规+站群服务器、1-10Gbps不限流量大带宽服务器等大量库存;VPS主机全场提供7折优惠码,同时针对部分特惠套餐无码直购每月仅1.99美元,支持使用PayPal或者支付宝等方式付款,有中英文网页及客服支持。爆款秒杀10台/天可选精品网/大...
6元虚拟主机是否值得购买?近期各商家都纷纷推出了优质便宜的虚拟主机产品,其中不少6元的虚拟主机,这种主机是否值得购买,下面我们一起来看看。1、百度云6元体验三个月(活动时间有限抓紧体验)体验地址:https://cloud.baidu.com/campaign/experience/index.html?from=bchPromotion20182、Ucloud 10元云主机体验地址:https:...
官方网站:点击访问特网云官网活动方案:===========================香港云限时购==============================支持Linux和Windows操作系统,配置都是可以自选的,非常的灵活,宽带充足新老客户活动期间新购活动款产品都可以享受续费折扣(只限在活动期间购买活动款产品才可享受续费折扣 优惠码:AADE01),购买折扣与续费折扣不叠加,都是在原价...