2

我刚开始学习 C# .NET 课程,发现它的简单程度真的很迷人。我已经使用 C++ 多年了,所以简单的性质实际上让我感到有些困惑。

我想按照这些思路做一些事情......

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

从 C# .NET 应用程序中执行此操作会很容易,还是我仍然与 C++ 处于同一条船上(构建 libcurl,获取一堆其他库等)?

4

1 回答 1

4

您可以这样创建WebClient的实例:

 // 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));

我没有机会对此进行测试,但这个片段至少应该让你按照正确的方式工作。

于 2011-01-14T15:51:00.667 回答