开发者

.Net SDK or samples for OpenSRS API? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
开发者_C百科

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 9 years ago.

Improve this question

OpenSRS from Tucows has a reseller API (or rather several APIs) to allow you to register domains, manage DNS settings etc.

They have API Toolkits for PHP and Ruby, but does anyone know of a .Net SDK, or have any sample code that they can share, as a basic starting point for the API?

Many thanks, Tim


use the XML API specification

And the following is a pseudo implementation of how you would send your xml request:

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;         
    }

}


http://opensrsdotnet.sourceforge.net/


Why not using the PHP to ASP.NET 1.x Migration Assistant

I described my findings about converting an API here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜