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

624 ℃
$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);

php语法中如何判断当前变量是数组还是对象

php中什么函数可以把字符串转数组

js接口批量新增参数(?/&)后缀不一样

php二维数组利用语句和函数求平均值

php如何去掉二维数组中的key

标签: explode, is_array, 接口

上面是“用php给阿里云写一个接口,判断域名是否已经被注册过”的全面内容,想了解更多关于 php入门 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_1519.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

vue路由跳转如何在新窗口打开?
wordpress函数如何查询友情链接详情(get_bookmark)
帝国cms效果之如何调用WordPress博客最新文章的方
wordpress如何用代码设置置顶文章?
织梦后台文章列表中显示自定义字段的方法