开发者

Using WHMCS API with a C# .NET Application

I just started taking a class on C# .NET and have found it really fascinating how simple it is. I have been using C++ for years, so the simplistic nature is actually hitting me as somewhat confusing.

I would like to do something along these lines...

http://wiki.whmcs.com/API:Example_Usage

Would it be easy to do this from a C# .NET application, or would I still be in abou开发者_StackOverflow中文版t the same boat as C++ (build libcurl, grab a bunch of other libs, etc)?


You could create and instance of WebClient thus:

 // Instantiate the WebClient object
 WebClient WHMCSclient = new WebClient();

 // Prepare a Name/Value collection to hold the post values
 NameValueCollection form = new NameValueCollection();      
 form.Add("username", username);
 form.Add("password", password); // the password will still need encoding is MD5 is a requirement
 form.Add("action", "addinvoicepayment"); // action performed by the API:Functions
 form.Add("invoiceid", "1");
 form.Add("transid", "TEST");
 form.Add("gateway", "mailin");

 // Post the data and read the response
 Byte[] responseData = WHMCSclient.UploadValues("http://www.yourdomain.com/whmcs/includes/api.php", form);      

 // Decode and display the response.
 Console.WriteLine("\nResponse received was \n{0}",Encoding.ASCII.GetString(responseData));

I've not had a chance to test that but this snippet should at least have you working along the right lines.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜