用php给阿里云写一个接口,判断域名是否已经被注册过

2024年09月15日 建站教程

$domain = htmlspecialchars(trim($_GET['domain']));
if(!empty($domain)){
	$do = "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" . $domain;//调用接口
	$xml_data = file_get_contents($do);
	$xml_arr = (array)simplexml_load_string($xml_data);//simplexml_load_string()
	if(is_array($xml_arr)&&!empty($xml_arr)){
		$info=explode(":",$xml_arr["original"]);
		if($info[0]==210){
			$result = array(
				'code'=>10000,
				'domain'=>$domain,
				'msg'=> '该域名可以注册'
			);
		}else if($info[0]==211){
			$result = array(
				'code'=>10001,
				'domain'=>$domain,
				'msg'=> '该域名已经被注册'
			);
		}else if($info[0]==212){
			$result = array(
				'code'=>10002,
				'domain'=>$domain,
				'msg'=> '域名参数错误,请输入的域名格式'
			);
		}else if($info[0]==213){
			$result = array(
				'code'=>10003,
				'domain'=>$domain,
				'msg'=> '查询异常,请稍后再试'
			);
		}else{
			$result = array(
				'code'=>10004,
				'domain'=>$domain,
				'msg'=> '查询异常,请稍后再试'
			);
		}
	}
}
function showjson($arr){
    header("Content-Type: application/json; charset=utf-8");
    exit(json_encode($arr,320));
}
showjson($result);

本文链接:http://so.lmcjl.com/news/13088/

展开阅读全文
相关内容