-
Notifications
You must be signed in to change notification settings - Fork 5
MakeCall()
Besides the API Functions the wrapper suplies one more function that will allow to make a call a API Action without using the preset functions
Initialize the class Call()
that need the following arguments (by this order)
- WHMCS API Username
- WHMCS API Password
- WHMCS API Access Key What's This?
- WHMCS User FrontEnd URL (ex: http://example.com/whmcs)
Create a NameValueCollection
and when initializing set the action (it's not necessary to be at initialization but it's best as it's a required field when performing any api call) Check all WHMCS API Actions
NameValueCollection params = new NameValueCollection()
{
{ "action", "SomeApiAction" }
};
Add the rest of the necessary parameters
Make the call by using the function MakeCall()
with accepts an NameValueCollection to set the request, all the other necessary fields are aready set because they were defined when initializing the class
The function MakeCall returns a JSON String
Here's an example of the use of the MakeCall()
function
using WHMCS_API
using System.Collections.Specialized
namespace YourApp
{
class YourClass
{
private type YourFunction()
{
NameValueCollection requestData = new NameValueCollection()
{
{ "action", "ValidateLogin" }
{ "email", "some_email@example.com" }
{ "password2", "PlainTextPassword" }
};
Call whmcs = new Call("WHMCS_USERNAME", "WHMCS_PASSWORD", "WHMCS_ACCESSKEY", "WHMCS_USERFRONTEEND_URL");
string result = whmcs.MakeCall(requestData);
}
}
}
PCDev Open Source Development Team 2017