不想去查询备案号再填写到网站上面,而且有时候更换备案了这个还要重新去获取信息,给大家带来一个很方便的方法自动获取备案号。
<?php
header("Content-type: application/json; charset=utf-8");
echo "{document.write('" . ok(get_Domain()) ."');}";
function ok($url){
$APIurl = urldecode(base64_decode('aHR0cHMlM0ElMkYlMkZhcGkub29vbW4uY29tJTJGYXBpJTJGaWNw'));
$apiKey = '';//获取apiKey地址:https://api.ooomn.com/user/order/25,注册后免费获取
$data = OooMn('' . $APIurl . '','apiKey=' . $apiKey . '&domain=' . $url . '');
$data = json_decode($data, true);
$info = $data['icp'];
return $info ;
}
function get_Domain()
{
$scriptpath = str_replace('\\', '/', $_SERVER['SCRIPT_NAME']);
$sitepath = substr($scriptpath, 0, strrpos($scriptpath, '/'));
$siteurl = ($_SERVER['SERVER_PORT'] == '443' ) . $_SERVER['HTTP_REFERER'] . $sitepath;
return $siteurl;
}
function OooMn($url, $post = 0 , $header = 0)
{
$ua = $_SERVER['HTTP_USER_AGENT'];
$referer = $_SERVER['HTTP_REFERER'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:*/*";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if ($header) {
curl_setopt($ch, CURLOPT_HEADER, true);
}
curl_setopt($ch, CURLOPT_REFERER, $referer);
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($ch);
curl_close($ch);
return $content;
}
网站实现调用
此时在你需要调用显示的地方输入以下代码,即可实现ICP备案号的自动获取并显示。
<a href="https://beian.miit.gov.cn" target="_blank"><script src="这里填入自动获取地址"></script></a>
直接调用我的
如果你嫌麻烦不想去创建的话也可以直接使用我已经创建好的。
直接选择下面任一代码放到需要展示ICP备案号的地方即可。
无图标的调用代码
<a href="https://beian.miit.gov.cn" target="_blank"><script src="https://api.ooomn.com/api/icps"></script></a>
带图标的调用代码
<a href="https://beian.miit.gov.cn" target="_blank"><img src="https://cdn.ooomn.com/images/beian.png" style="height: 17px;"><script src="https://api.ooomn.com/api/icps"></script></a>