使用WHMCS API与C#.NET应用程序 [英] Using WHMCS API with a C# .NET Application
问题描述
我刚开始服用的C#.NET类,并发现它确实令人着迷是多么简单。我一直使用C ++多年,所以简单的本质实际上是打我,有点混乱。
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
难道是简单地从C#.NET应用程序做到这一点,或者我仍然会在大约同一条船上,C ++(建设libcurl的,抢?一帮其他的库等)
Would it be easy to do this from a C# .NET application, or would I still be in about the same boat as C++ (build libcurl, grab a bunch of other libs, etc)?
推荐答案
您可以创建和的 WebClient的这样的:
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.
这篇关于使用WHMCS API与C#.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!