Home  >  Article  >  Backend Development  >  有道搜索和IP138的IP的API接口(PHP应用)_php实例

有道搜索和IP138的IP的API接口(PHP应用)_php实例

WBOY
WBOYOriginal
2016-06-07 17:25:08958browse
复制代码 代码如下:

$myip = $_SERVER["REMOTE_ADDR"];
//ip138 http://wap.ip138.com/ip.asp?ip=www.myolnet.com
//youdao http://www.youdao.com/smartresult-xml/search.s?type=ip&q=ip
$ipinfo=fcontents("http://www.youdao.com/smartresult-xml/search.s?type=ip&q=".$myip);//此代码为有道ip库
if(strpos($ipinfo,'北京') > 0) {
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://www.php.net");
}
?>
Statement:
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