$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入门 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_1519.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!