检测域名是否被墙API接口源码

警告
本文最后更新于 2022-06-10,文中内容可能已过时。

昨日博客有个人问有没有检测域名被墙的。

今儿根据易名网的接口写了一个。

速度还可以的,大家可以拿来用用!

 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
<?php
/*
* 检测域名是否被墙
* 2dph.com
*/
//查询域名
$domain = '2dph.com';

$post = array(
	'func'	=>	'true'
	,'m'		=>	'check'
	,'a'		=>	'check'
	,'domain'=>	$domain
);
$rel = _qiang($post);
$arr = json_decode($rel,true);
if ($arr['strcode'] == 1) {
	echo '该域名没有被墙';
}elseif ($arr['strcode'] == -1) {
	echo '该域名被墙了';
}else{
	echo '查询失败';
}

function _qiang($post) {
	// 创建一个新cURL资源
	$ch = curl_init();
	// 设置URL和相应的选项
	curl_setopt($ch, CURLOPT_URL, 'https://tool.22.cn/ajax/qiang.ashx?'.time());
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	//将curl_exec()获取的信息以文件流的形式返回,而不是直接输出
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	//POST请求
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
	//执行cURL会话
	$response = curl_exec($ch);
	// 关闭cURL资源,并且释放系统资源
	curl_close($ch);
	return $response;
}

源码下载:传送门

Buy me a coffee~
支付宝
微信
0%