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 に答える