ICP备案信息查询 PHP 源代码

调用方法 icp.php?d=www.gov.cn

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?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;
}

?>

🔰本文标题: ICP备案信息查询 PHP 源代码

🔞本文链接: https://193.gs/PHPiacybwan/index.html

🌡️本文总热度