Home > Backend Development > PHP Tutorial > 登录用户地界别布

登录用户地界别布

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:19:05
Original
789 people have browsed it

登录用户地区分布
想获得登录用户的国家分布情况。
现在登录用户表里只有记录用户的IP
感觉用IP地址转化为国家花费太长时间了(每一个都得在一个网址上转国家?)
大家有没有好的方法?
可以根据IP知道用户的国家?

------解决方案--------------------
这个比较简单,你使用api接口就可以了。比如新浪api。查询后你在自己取出值显示OK

JScript code

<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>
<script type="text/javascript">
//format参数设置返回格式 js/json
//ip 要查询IP 可选
//反回格式如下:
//var remote_ip_info = {"ret":1,"start":"117.89.35.0","end":"117.89.35.255","country":"\u4e2d\u56fd","province":"\u6c5f\u82cf","city":"\u5357\u4eac","district":"\u767d\u4e0b","isp":"\u7535\u4fe1","type":"","desc":""};
console.log(remote_ip_info["country"]+’,'+remote_ip_info["province"]+"省"+’,'+remote_ip_info["city"]+"市")//中国,江苏省,南京市
</script>
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
    
  
function get_ip_place(){       
  
$ip=file_get_contents("http://fw.qq.com/ipaddress");       
  
$ip=str_replace('"',' ',$ip);       
  
$ip2=explode("(",$ip);       
  
$a=substr($ip2[1],0,-2);       
  
$b=explode(",",$a);       
  
return $b;       
  
}       
  
$ip=get_ip_place();       
  
print_r($ip); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template