http協議:
http://api.youripapi.com/ip/
https協議:
https://api.youripapi.com/ip/
* API接口可能會因為各種網絡原因和攻擊都可能産生阻斷,請開發時做好冗餘和異常處理
* 當HTTP請求返回的狀態碼非200時,請做異常處理,比如 202 狀態碼造成的原因可能是無效Token、餘額不足、格式錯誤
PHP調用iP查詢接口示例:
<?php
$ip = '117.25.13.123';
$datatype = 'txt';
$url = 'https://api.youripapi.com/ip/?ip='.$ip.'&datatype='.$datatype;
$header = array('token:00d5cb1fac5dc5cbfe2ff218292a2dfd33');
echo getData($url,$header);
function getData($url,$header){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,3);
$handles = curl_exec($ch);
curl_close($ch);
return $handles;
}
?>
<?php
//js引入頁面 callback jsonp回調地址
$ip = '117.25.13.123';
$mid = 35553;
$oid = 2;
$token = '00d5cb1fac5dc5cbfe2ff218292a2dfd33';
$sign = md5("ip=".$ip."&token=".$token);
$url = 'https://api.youripapi.com/ip/';
//以下是js引入代碼
/***
/*<script type="text/javascript" src="<?php echo $url.'?ip='.$ip.'&callback=find&oid='.$oid.'&mid='.$mid.'&sign='.$sign;?>"></script>
**/
?>