-
Notifications
You must be signed in to change notification settings - Fork 5
ModuleChangePassword()
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 ModuleChangePassword(int ServiceID, string NewPassword, bool getException = true)
Input:
- ServiceID: The service ID to run the action for (required)
- NewPassword: A new password to assign to the service (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 changepw = _api.ModuleChangePassword(1, "12345Test", 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/modulechangepw/
using WHMCS_API;
namespace YourApp
{
class YourClass
{
public void YourFunction()
{
API _api = new API("username", "password", "accesskey", "url");
//we want to know the error in this case
try
{
bool mcpw = _api.ModuleChangePassword(1, "SomePassword");
Console.WriteLine("Seems that you changed the password successfully!");
}
catch (Exception ex)
{
Console.WriteLine("Opps, you have a error here... {0}", ex.InnerException.Message);
}
}
}
}
PCDev Open Source Development Team 2017