php歸屬地
Ⅰ 在html頁面輸入手機號碼,提交後php,查詢手機手機歸屬地,記錄該次查詢到mysql數據,並將歸屬地輸出到網頁
查詢歸屬地可以去網上找開放介面調用 前台輸入手機號碼查詢的時候調用介面 介面調用結果一般是json格式的把他轉成數組按照鍵名拿到你要的數據傳參到前台頁面顯示就可以了 同時你也可以把拿到的數據存入資料庫
Ⅱ 如何用php編寫手機歸屬地查詢果殼網
代碼如下:
<?php
header(「Content-Type:text/html;charset=utf-8″);
if(isset($_GET['number'])){
$url=『http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo';
$number=$_GET['number'];
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,「mobileCode={$number}&userId=」);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$data=curl_exec($ch);
curl_close($ch);
$data=simplexml_load_string($data);
if(strpos($data,『http://')){
echo『手機號碼格式錯誤!';
}else{
echo$data;
}
}
?>
<formaction=」mobile.php」method=」get」>
手機號碼:<inputtype=」text」name=」number」/><inputtype=」submit」value=」提交」/>
</form>
Ⅲ php用IP查詢歸屬地
class ip_location
{
 function init()
 {
  $this->wrydat = 'ip_area.dat';
  
  $this->fp = fopen($this->wrydat, 'rb');
  $this->getipnumber();
  $this->getwryversion();
  
  $this -> REDIRECT_MODE_0 = 0;
  $this -> REDIRECT_MODE_1 = 1;
  $this -> REDIRECT_MODE_2 = 2;
 }
 
 function get($str)
 {
  return $this->$str;
 }
 
 function set($str,$val)
 {
  $this->$str = $val;
 }
 
 function getbyte($length,$offset=null)
 {
  !is_null($offset) && fseek($this->fp, $offset, SEEK_SET);
  
  return fread($this->fp, $length);
 }
 
 function packip($ip)
 {
  return pack('N', intval(ip2long($ip)));
 }
 
 function getlong($length=4, $offset=null)
 {
  $chr=null;
  for($c=0;$length%4!=0&&$c<(4-$length%4);$c++)
  {
   $chr .= chr(0);
  }
  $var = unpack( 'Vlong', $this->getbyte($length, $offset).$chr);
  return $var['long'];
 }
 
 function getwryversion()
 {
  $length = preg_match("/coral/i",$this->wrydat)?26:30;
  $this->wrydat_version = $this->getbyte($length, $this->firstip-$length);
 }
 
 function getipnumber()
 {
  $this->firstip = $this->getlong();
  $this->lastip = $this->getlong();
  $this->ipnumber = ($this->lastip-$this->firstip)/7+1;
 }
 
 function getstring($data='', $offset=NULL)
 {
  $char = $this->getbyte(1,$offset);
  while(ord($char) > 0)
  {
   $data .= $char;
   $char = $this->getbyte(1);
  }
  return $data;
 }
 
 function iplocaltion($ip)
 {
  $ip = $this->packip($ip);
  $low = 0;
  $high = $this->ipnumber-1;
  $ipposition = $this->lastip;
  while($low <= $high)
  {
   $t = floor(($low+$high)/2);
   if($ip < strrev($this->getbyte(4,$this->firstip+$t*7)))
    $high = $t - 1;
   else
   {
    if($ip > strrev($this->getbyte(4,$this->getlong(3))))
     $low = $t + 1;
    else
    {
     $ipposition = $this->firstip+$t*7;
     break;
    }
   }
  }
  return $ipposition;
 }
 
 function getarea()
 {
  $b = $this->getbyte(1);
  switch(ord($b))
  {
   case $this -> REDIRECT_MODE_0 :
    return '';
    break;
   case $this -> REDIRECT_MODE_1:
   case $this -> REDIRECT_MODE_2:
    return $this->getstring('',$this->getlong(3));
    break;
   default:
    return $this->getstring($b);
    break;
  }
 }
 
 function getiplocation($ip)
 {
  $ippos = $this->iplocaltion($ip);
  $this->ip_range_begin = long2ip($this->getlong(4,$ippos));
  $this->ip_range_end = long2ip($this->getlong(4,$this->getlong(3)));
  $b = $this->getbyte(1);
  switch(ord($b))
  {
   case $this -> REDIRECT_MODE_1:
    $b = $this->getbyte(1,$this->getlong(3));
    if(ord($b) == $this -> REDIRECT_MODE_2)
    {
     $countryoffset = $this->getlong(3);
     $this->area = $this->getarea();
     $this->country = $this->getstring('',$countryoffset);
    }
    else
    {
     $this->country = $this->getstring($b);
     $this->area = $this->getarea();
    }
    break;
   case $this -> REDIRECT_MODE_2:
    $countryoffset = $this->getlong(3);
    $this->area = $this->getarea();
    $this->country = $this->getstring('',$countryoffset);
    break;
   default:
    $this->country = $this->getstring($b);
    $this->area   = $this->getarea();
    break;
  }
 }
}
---------------------------------------------------------------
調用方法:
$iploca = new ip_location;
 $iploca -> init();
 $iploca -> getiplocation($ip);
 
 $area['country'] = str_replace(array('CZ88.NET'), '', $iploca -> get('country'));
 $area['area'] = str_replace(array('CZ88.NET'), '', $iploca -> get('area'));
 
 $area['country']=='' && $area['country']='未知';
 $area['area']=='' && $area['area']='未知';
 return $area;
Ⅳ PHP IP地址歸屬地查詢的介面
function GetIpLookup($ip = ''){
            $res = @file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' . $ip);
            if(empty($res)){ return false; }
            $jsonMatches = array();
            preg_match('#\{.+?\}#', $res, $jsonMatches);
            if(!isset($jsonMatches[0])){ return false; }
            $json = json_decode($jsonMatches[0], true);
            if(isset($json['ret']) && $json['ret'] == 1){
                $json['ip'] = $ip;
                unset($json['ret']);
            }else{
                return false;
            }
            return $json;
        }
        $ipInfos = $this->GetIpLookup('222.223.191.12'); //.com IP地址
        var_mp($ipInfos);
Ⅳ php 手機號歸屬地顯示查詢
網上有很多。。。。要自己寫個的話 給你個思路吧:
1. 很多網站都有手機歸屬查詢介面, 或者查詢網站
2. 模擬一個正常的請求到某個網站的查詢介面
3. 從獲取的HTML中 用正則或者其他方法 提取出需要的字元串來。。。
4. 完了。
Ⅵ php 如何截取 ip地址的四組數字
有的時候,用explode函數要比正則既簡單又高效,你只是簡單判斷一下,何必非要用正則把自己繞進去呢(雖然看上去用正則很帥氣,但說實話,正則的處理速度並不可觀,除非應對復雜字串匹配,其他函數不能勝任的時候,正則才是不可替代的選擇),用一個「.」分開首先count判斷是否為4組數據,然後再將其轉換成整數,之後你想怎麼判斷就怎麼判斷咯。
Ⅶ 免費的API-手機號碼歸屬地介面
 手機號碼歸屬地介面:根據手機號碼或手機號碼的前7位,查詢手機號碼歸屬地信息,包括省份 、城市、區號、郵編、運營商和卡類型。
    介面文檔: https://www.juhe.cn/docs/api/id/11  
   如要使用,則需要先申請APPKEY,通過審核,之後就可以無限次免費使用。
 介面地址: http://apis.juhe.cn/mobile/get 
   支持格式:json/xml
   請求方式:get
   請求示例: http://apis.juhe.cn/mobile/get?phone=13429667914&key= 您申請的KEY
   調用樣例及調試工具: API測試工具 
   請求參數說明:
返回參數說明:
JSON返回示例:
XML返回示例:
系統級錯誤碼參照:
錯誤碼格式說明(示例:200201):
 PHP: 手機號碼歸屬地查詢 
   Python: 手機號碼歸屬地介面調用示例 
   C#: 手機號碼歸屬地介面調用示例 
   Go: 手機號碼歸屬地介面調用示例 
   JAVA: 手機號碼歸屬地介面調用示例 
Ⅷ <thinkphp> 怎麼獲取手機號歸屬地啊,急求完整代碼。
你都會用thinkPHP了。
那麼我就認為你php基本的也都OK
既然OK,給你這些手機歸屬地API 那麼你就可以搞定了
淘寶網
API地址:http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=15850781443
參數:
tel:手機號碼
返回:JSON
拍拍
API地址:http://virtual.paipai.com/extinfo/GetMobileProctInfo?mobile=15850781443&amount=10000&callname=getPhoneNumInfoExtCallback
參數:
mobile:手機號碼
callname:回調函數
amount:未知(必須)
返回:JSON
財付通
API地址:http://life.tenpay.com/cgi-bin/mobile/MobileQueryAttribution.cgi?chgmobile=15850781443
參數:
chgmobile:手機號碼
返回:xml
百付寶
API地址:https://www.fubao.com/callback?cmd=1059&callback=phone&phone=15850781443
參數:
phone:手機號碼
callback:回調函數
cmd:未知(必須)
返回:JSON
115
API地址:http://cz.115.com/?ct=index&ac=get_mobile_local&callback=jsonp1333962541001&mobile=15850781443
參數:
mobile:手機號碼
callback:回調函數
返回:JSON
有道api介面
介面地址:http://www.you.com/smartresult-xml/search.s?type=mobile&q=13892101112
參數說明:
type:參數手機歸屬地固定為mobile
q:手機號碼
返回XML格式:
Ⅸ php網站 我有ip.dat資料庫,如何調取ip.dat並將訪客的IP地址、歸屬地和時間寫入.tx
PHP可以獲取到訪客的IP,然後查詢歸屬地,這個網上很多介面有提供
Ⅹ thinkphp根據身份證怎麼獲取所在地區
方法很多,這里舉出兩種
- 通過一些平台介面進行查詢,例:有道身份證查詢這個(貌似封了),可以自行網路下 
- 自建資料庫查詢,原理:身份證號碼的前6位是用來做地區區別碼的,所以只要找到各個地區的區別碼,用正則匹配就可以知道身份證所在地區了 
