views:

133

answers:

2

Hi,

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

+1  A: 

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

}
Mark
Thanks for sharing this. Not quite the SDK I was hoping to find, but is a good example of how to make the request. Ideally I'd like to find a library which has all of the OpenSRS methods ready to use.
TimS
+1  A: 

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

I described my findings about converting an API here

dampee
Great suggestion, thanks, but still not quite what I'm after.
TimS