西部数码域名查询API接口代码
$bmkj_domain = input('domain'); $suffix_array=input('suffix/a'); $suffix = ''; //此处自行判断根域名及后缀是否合法 for($i=0;$i<count($suffix_array);$i++){ $i<count($suffix_array)-1 ? $suffix.=$suffix_array[$i]."," : $suffix.=$suffix_array[$i]; } //西部数码域名API接口查询核心代码 $sys_api = "http://api.west263.com/api/";//西部数码API地址 $sys_user= "account";//代理账号 $sys_pass= "123456";//API密码 $cmdstrng = "domainname"."\r\n"."check"."\r\n"."entityname:domain-check"."\r\n"."domainname:".$bmkj_domain."\r\n"."suffix:".$suffix."\r\n"."."."\r\n"; $md5sing=md5( $sys_user.$sys_pass .substr($cmdstrng,0,10)); $postdata=$sys_api."?userid=".$sys_user."&versig=".$md5sing."&strCmd=".urlencode($cmdstrng); $return =file_get_contents($postdata); $xml = simplexml_load_string($return); $status=$xml->returncode; if($status==200){//查询状态正确 //可注册域名 if(!empty($xml->info->record->allow)){ $allow = $xml->info->record->allow; $allow_arr = explode(',', $allow); } //不可注册域名 if(!empty($xml->info->record->registered)){ $disallow = $xml->info->record->registered; $disallow_arr = explode(',', $disallow); } //未查到域名状态:网络原因、后缀未开放... if(!empty($xml->info->record->error)){ $error = $xml->info->record->error; $error_arr = explode(',', $error); } }else{ $fail = "查询失败"; //调试查询错误原因 //$this->assign('abc',"查询错误:".iconv( "gb2312", "UTF-8//IGNORE" , $xml->returnmsg)); }
TIPS:请把你网站的IP地址填到西部数码代理商的API接口配置里
上一篇: 《建站管家》二次开发文档