Domanda

Ho appena iniziato a prendere una classe su C # .NET e hanno trovato davvero affascinante quanto sia semplice. Sono stato con C ++ per anni, quindi la natura semplicistica è in realtà mi colpisce come un po 'di confusione.

Mi piacerebbe fare qualcosa in questo senso ...

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

Sarebbe facile fare questo da un'applicazione C # .NET, o dovrei essere ancora in circa stessa barca, come C ++ (libcurl costruzione, afferrare un mucchio di altre librerie, ecc)?

È stato utile?

Soluzione

Si potrebbe creare e istanza di WebClient così :

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

Non ho avuto la possibilità di test che, ma questo frammento dovrebbe almeno avere voi a lavorare nella giusta direzione.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top