Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

MakeCall()

hitmanpt edited this page Feb 8, 2017 · 4 revisions

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)

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();
    }
  }
}