互聯網開(kāi)發&品牌全案設計(jì)

12年(nián) 實戰經驗,品質服務

蘇州網絡公司教你(nǐ)如(rú)何通(tōng)過JS調用(yòng)萬網域名查詢接口

2012-03-18 關鍵詞: 2999

1.新建一(yī)個(gè)aspx頁面,删除前台代碼,後台代碼如(rú)下(xià)

try
             &nb₽sp;  {
         &nb sp;          if (Request.QueryString["doma↔ins"] != null)
           &nbs©p;        {
         &n↔bsp;              Str ingBuilder sb = new StringBuilder();
              &nb sp;         sb.Append("["§);
          &nbs↑p;        &nbs p;    foreach (string domain in Request.QueryString[&∏quot;domains"].Split(','))
           &nbs←p;           ≥; {
              &n♠bsp;             WebRequest w•r = WebRequest.Create("http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=" + domain);
               &nπbsp;         ‌;   //wr.Timeout = 10000;
           &​nbsp;           &nbs<p;    string strHtml = new StreamReader(wr.GetResp<onse().GetResponseStream()).ReadToEnd();
            &λnbsp;               Xm¥lDocument xd = new XmlDocument();
         &nbs♠p;                   xd.LoadXml(strHtml);
           π;              &n★bsp;  XmlNode root = xd.SelectSingleNode("prop♠erty");

            &γnbsp;             &←nbsp; sb.Append(",{\"returncode\":\"" + r‌oot.ChildNodes[0].InnerText + "\",\"key\":\"" + ro™ot.ChildNodes[1].
          Ω;         '          &®nbsp;  InnerText + "\",\"original\":\"" + ro"ot.ChildNodes[2].InnerText + "\"}");
          ✘              ♦}
         &γnbsp;              sb.Append(&q±uot;]");
           &≥nbsp;            string s = sb.ToString().Re place("[,","[");
              &∞nbsp;         Response.Write(s);
           ↕         }
            &n bsp;   }
            ♥    catch (Exception ex)
              &n¶bsp; {
                     Response.Write(ex.ToString())φ;
        &nbs p;       }

2.通(tōng)過jquery ajax的(de)方式,調用(yòng)前面新建的(de)aspx頁,如(rú)圖

 $.ajax({
               &nb₹sp;    type: "get",
         &λnbsp;          dataType: "json",
          ↓;          url: 'checkdomain.aspx',
     data: 'domains='+domains,//此處傳遞多(duō)個↔(gè)域名到(dào)checkdomain.aspx,以逗号分(fēn)隔
     cache: false,
           &n★bsp;        success: function (returndata) {
       $.each(returndata, function(i, n){
       //n.original
       //n.key
      })
        &nb&sp;           }
          &‍nbsp;     });

萬網域名注冊查詢接口(API)說(shuō)明(míng)

1、域名查詢
接口采用(yòng)HTTP,POST,GET協議(yì):
調用(yòng)URL:http://panda.www.net.cn/cgi-bin/check.cgi
參數(shù)名稱:area_domain 值為(wèi)标準域名,例:hichina.com
調用(yòng)舉例:
http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=qxue8.com

返回XML:

<?xml version="1.0" encoding="gb2312"?>
<property>
<returncode>200</returncode>
<key>qxue8.com</key>
<original>211 : Domain name is not available</original>
</property>
返回 XML 結果說(shuō)明(míng):
returncode=200 表示接口返回成功
key=***.com表示當前check的(de)域名
original=210 : Domain name is available     表示域名可(kě)以注↔冊
original=211 : Domain name is not available 表示域名已經注冊
original=212 : Domain name is invalid   表示域名參數(shù)傳輸錯(cuò)誤
 

 

欄目 案例 售後 電(diàn)話(huà)