Home > php教程 > PHP源码 > 批量在线查询手机号码归属地信息,淘宝接口,实时更新。外行作品,大牛完善

批量在线查询手机号码归属地信息,淘宝接口,实时更新。外行作品,大牛完善

PHP中文网
Release: 2016-05-26 08:21:08
Original
1598 people have browsed it

php代码

<?php
$handle = fopen("tel.txt", "r");
if ($handle) {
    //打开要写入的文件对象
   
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
		$content = get_mobile_area(trim($buffer));
		echo "手机号:   ".$buffer."		归属地:   ".$content.&#39;<br/>&#39;;
		if(strpos($content,&#39;北京&#39;) !== false){
			 $file=fopen("北京.txt","a+");
			 fwrite($file,trim($buffer)."	".$content."\n");
			 fclose($file);
			}else if(strpos($content,&#39;上海&#39;) !== false){
				 $file1=fopen("上海.txt","a+");
				 fwrite($file1,trim($buffer)."	".$content."\n");
				 fclose($file1);
				}else{
					 $file2=fopen("外省.txt","a+");
					 fwrite($file2,trim($buffer)."	".$content."\n");
					 fclose($file2);
					}

		
		
		
	    
    }
    
    fclose($handle);
}

function get_mobile_area($mobile){ 
if($mobile!=&#39;&#39;){
    $sms = array(&#39;province&#39;=>&#39;&#39;, &#39;supplier&#39;=>&#39;&#39;);    //初始化变量 
    //根据淘宝的数据库调用返回值 
    $url = "http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=".$mobile."&t=".time(); 

    $contents = file_get_contents($url); 

    $sms[&#39;province&#39;] = substr($contents, "56", "4");  //截取字符串 
    $sms[&#39;supplier&#39;] = substr($contents, "81", "4"); 

    return $sms[&#39;province&#39;]."	".$sms[&#39;supplier&#39;];
	
	}
} 
?>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template