-
Notifications
You must be signed in to change notification settings - Fork 5
ModuleCustomCommand()
Through this explanation we assume that you have using WHMCS_API;
on the begining of the file
And the API()
class initialized as _api
If needed check the Getting Started page
Prototype: public bool ModuleCustomCommand(int ServiceID, string Command, bool getException = true)
Input:
- ServiceID: The service ID to run the action for (required)
- Command: The name of the custom function to run (required)
- getException: When this command results an error throws an Exception with the error message otherwise only returns false (optional [default: true])
Output: Boolean value whether the command ran successfully or not
Exception: "An API Error has Ocurred" witch contains an inner exception with further explanation of the error (enabled if getException is set to true)
To call it just use bool mcc = _api.ModuleCustomCommand(1, "someCommand", false);
The result will be true if the command ran successfully and in this case if there is an error it will be false. To get the error you need to change de last parameter (getException) to true (default value) if the getException is set to true and there was an error on the command an exception will be thrown, "An API Error has Ocurred", witch contains an inner exception with further explanation of the error
WHMCS API Reference: https://developers.whmcs.com/api-reference/modulecustom/
using WHMCS_API;
namespace YourApp
{
class YourClass
{
public void YourFunction()
{
API _api = new API("username", "password", "accesskey", "url");
bool mcc = _api.ModuleCustomCommand(1, "SomeCommand", false);
Console.WriteLine("Did the command ran without errors? {0}", mcc.ToString());
}
}
}
PCDev Open Source Development Team 2017