2

My question how to get https://www.example.com/includes/api.php. Means api.php file or related liberary. And how to use it.

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,
        http_build_query(
            array(
                'action' => 'AddUser',
                // See https://developers.whmcs.com/api/authentication
                'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
                'password' => 'SECRET_OR_HASHED_PASSWORD',
                'firstname' => 'John',
                'lastname' => 'Doe',
                'email' => 'john.doe@example.com',
                'password2' => 'password',
                'responsetype' => 'json',
            )
        )
    );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($ch);
    curl_close($ch);

1 Answers1

2

This is an external API example.

You need to complete few steps before using it.

Authentication
We recommend creating API Authentication Credentials as best practice for use when building API integrations. API Authentication Credentials can be setup and managed in Setup > Staff Management > Manage API Credentials and allow you to setup individual client identifiers and secrets for each API integration you create. Combined with API Roles, you can also limit the actions that a given API Authentication Credential can access and use allowing for secure and robust management of API access. Use of the WHMCS External API always requires Authentication. In some cases, the Internal API may also require authentication if the call relates to actions specific to an admin user.
For more information, please refer to https://docs.whmcs.com/API_Authentication_Credentials

Access Control
Access to the External API is IP restricted by default. To configure the IP addresses that are allowed to access and use the WHMCS API, login to your WHMCS admin area and navigate to Setup > General Settings > Security. From there you can add, remove and manage the allowed IPs. Each allowed IP you add also allows you to add a note useful for notating who/what/why the IP has been authorized for access.For cases where IP restriction is not feasible, an access key method is available instead. Please see https://developers.whmcs.com/api/access-control/ for further information.

For more information: https://blog.whmcs.com/133546/getting-started-with-the-whmcs-api

Caner
  • 92
  • 3