.Net SDK或OpenSRS API的示例?

时间:2010-03-26 10:21:34

标签: c# .net api

来自Tucows的OpenSRS有一个经销商API(或者更确切地说是几个API),允许您注册域名,管理DNS设置等。

他们拥有适用于PHP和Ruby的API工具包,但是有没有人知道.Net SDK,或者他们可以共享任何示例代码,作为API的基本起点?

非常感谢, 添

3 个答案:

答案 0 :(得分:4)

use the XML API specification

以下是如何发送xml请求的伪实现:

public class OpenSrs {

    private const string URL_BASE       = "https://horizon.opensrs.net:55443";
    private const string RSP_USERNAME   = "username";
    private const string PRIVATE_KEY    = "PrivateKey";

    public string SendWebRequest(string postData)
    {
            WebRequest request = WebRequest.Create(URL_BASE);

            request.Method = "POST";
            request.ContentType = "text/xml";
            request.Headers.Add("X-Username", RSP_USERNAME);
            request.Headers.Add("X-Signature", Utility.md5Hash(
                        Utility.md5Hash(postData + PRIVATE_KEY) + PRIVATE_KEY));

            byte[] dataArray = Encoding.ASCII.GetBytes(postData);

            request.ContentLength = dataArray.Length;

            Stream dataStream = request.GetRequestStream();
            dataStream.Write(dataArray, 0, dataArray.Length);
            dataStream.Close();

            WebResponse response = request.GetResponse();
            dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string strResponse = reader.ReadToEnd();

            reader.Close();
            dataStream.Close();
            response.Close();

            return strResponse;         
    }

}

答案 1 :(得分:3)

答案 2 :(得分:2)

为什么不使用PHP to ASP.NET 1.x Migration Assistant

我描述了关于转换API here

的调查结果