ICP备案信息查询 PHP 源代码

优秀源码 无标签
0 842
WIZ
WIZ 自成一派 2023-01-16 18:07:37
Lv:36级
调用方法 icp.php?d=www.gov.cn
<?php
error_reporting(0);
header("Content-type:application/json; charset=UTF-8");
header('Access-Control-Allow-Origin:*');
$domain = htmlspecialchars($_GET['d'],ENT_QUOTES);
$code = 500;
if ($domain) {
    $timeStamp = time();
    $authKey = md5("testtest" . $timeStamp);
    $token = json_decode(post("auth", "authKey=$authKey&timeStamp=$timeStamp", "", "application/x-www-form-urlencoded;"));
    $token = $token->params->bussiness;
    $query = json_decode(post('icpAbbreviateInfo/queryByCondition',"{'unitName': '$domain'}",$token,'application/json;'));
    $msg = $query->msg;
    $query = $query->params->list[0];
    if ($query) {
        $code = 200;
        $domain = $query->domain;
        $data = array(
            'serviceLicence' => $query->serviceLicence,
            'unitName'       => $query->unitName,
            'natureName'     => $query->natureName,
            'updateRecordTime' => $query->updateRecordTime,
        );
    }
}

$json = array(
    'code'  => $code,
    'domain'=> $domain,
    'data'  => $data,
    'msg'   => $msg
);
foreach ($json as $key => $val) {//清除null
    if (empty($val)) {
        unset($json[$key]);
    }
}
print_r(json_encode($json,128|256));

function post($url,$data,$token,$content){
    $miit = 'https://beian.miit.gov.cn/';
    $headers = array(
        "Content-Type: {$content}charset=UTF-8",
        "Origin: $miit",
        "Referer: $miit",
        "token: $token",
        "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36",
    );
    $options = array(
        'http' => array(
            'header'  => implode("\r\n", $headers),
            'method'  => 'POST',
            'content' => $data,
        ),
    );
    $contexts  = stream_context_create($options);
    $result = file_get_contents("https://hlwicpfwc.miit.gov.cn/icpproject_query/api/$url", false, $contexts);
    return $result;
}

 ?>



#0000FF
楼主签名:DNSWIZ 站长故事
回帖
回复列表

    遵守各国法律法规 严谨违规内容

    • QQ群:1140251126
    • Email:m@max.ooo
    • 本站可以自由发布正规网站外链
    • 本站域名皆为闲置域名可出售
    本站热帖
    01 ch.gs正在竞价 一起搞它 190
    02 域名行情兵败如山倒,势如破竹。 184
    03 SSL证书是不是个人网站的绊脚石 166
    04 微信开放个人注册服务号了没有门槛了? 165
    05 刚看到个xinyi.net过期了在抢注,我本地的生活站也倒闭了 157
    06 每一个都是好域名 153
    07 删除友情链接是不是友尽了? 149
    08 当前可用的开源论坛程序整理[2024] 144
    09 今天都在搞欧洲开放大学MBA证书 141
    10 频繁在各大域名群叫卖,其实和乞丐没什么区别! 137
    推荐主机