根据客户端IP去获取地区API接口

doudi2022-08-25PHP533

第一种淘宝IP接口

<?php
	$ip = $_SERVER['REMOTE_ADDR'];
	$url = 'http://ip.taobao.com/outGetIpInfo?ip=' . $ip . '&accessKey=alibaba-inc';
	$ip_content = file_get_contents($url);
	$ip_content = json_decode($ip_content, true);
	echo json_encode($ip_content);
?>	


第二种百度IP接口

<?php
	$ip = $_SERVER['REMOTE_ADDR'];
	$url = 'http://opendata.baidu.com/api.php?query=' . $ip . '&co=&resource_id=6006&oe=utf8';
	$ip_content = file_get_contents($url);
	$ip_content = json_decode($ip_content, true);
	echo json_encode($ip_content);
?>


发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。