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

流氓凡 PHP程序源码 2019-04-08 5.44 K 0
<?php
$domain = $_GET["url"]; //获取域名以GET的方式
$post = array(
	'func'	=>	'true'
	,'m'		=>	'check'
	,'a'		=>	'check'
	,'domain'=>	$domain
);
$rel = _qiang($post);
$arr = json_decode($rel,true);
if ($arr['strcode'] == 1) {
	echo '<script>alert("恭喜,该域名没有墙!");</script>';
}elseif ($arr['strcode'] == -1) {
	echo '<script>alert("注意,该域名被墙了!");</script>';
}else{
	echo '<script>alert("查询失败!");</script>';
}

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

成品接口地址:https://wslmf.com/api/chost.php?url=你的域名

看到接口地址就知道源码使用方法了吧!

评论