备案接口 php,分享一个备案查询的api接口源码,可自行开发对接备案API接口

<?php

error_reporting(0);

$url=$_GET['url'];

var_dump();

if(!isset($url)){

echo'参数错误!';

die;

}elseif($url==''){

echo'未输入要查询的域名!';

}else{

$str=file_get_contents('http://icp.chinaz.com/'.$url);

$sitenames=getSubstr($str,'

','>[');

preg_match('/(.*?)/',$str,$name);

preg_match('/

(.*?)/',$str,$nature);

preg_match('/

(.*?)/',$str,$icp);

preg_match('/

(.*?)/',$sitenames,$sitename);

preg_match('/

(.*?)/',$str,$siteindex);

$time=getSubstr($str,'审核时间','

');

//echo$time;

preg_match('/

(.*?)/',$time,$time);

if(strpos($str,'未备案或备案取消')==0){

print_r(json_encode(array('name'=>$name[1],'siteindex'=>$siteindex[1],'nature'=>$nature[1],'icp'=>$icp[1],'sitename'=>$sitename[1],'img'=>'http://icp.chinaz.com'.$icp[2],'time'=>$time[1]),320));

}else{

print_r(json_encode(array('code'=>-1,'msg'=>'未查询到备案!'),320));

}

}

functiongetSubstr($str,$leftStr,$rightStr){

$left=strpos($str,$leftStr);

$right=strpos($str,$rightStr,$left);

if($left

returnsubstr($str,$left+strlen($leftStr),$right-$left-strlen($leftStr));

}

?>

使用方法:

把源码保存到beian.php,然后访问“域名/beian.php?url=查询域名”即可。

暂无评论

暂无评论...