自动获取网站ICP备案号源码

博客介绍了网站自动获取并显示ICP备案号的方便方法,避免手动查询和更换备案时重新获取信息的麻烦。还提供了直接调用已创建代码的方式,包括无图标的调用代码和带图标的调用代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

不想去查询备案号再填写到网站上面,而且有时候更换备案了这个还要重新去获取信息,给大家带来一个很方便的方法自动获取备案号。

<?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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值