I'm trying to use the WHMCS API, for example to get client. So when I run the file PHP,it gave me this error in Json:
{"result":"error","message":"Authentication Failed"}
and when I test username and password they authenticate in the website.
Please suggest a solution.
<?php
// Création d'une ressource cURL
$ch = curl_init();
//L'URL à récupérer
curl_setopt($ch, CURLOPT_URL, 'https://example.com/includes/api.php');
//TRUE pour que PHP fasse un HTTP POST
curl_setopt($ch, CURLOPT_POST, 1);
//les données à passer lors d'une opération de HTTP POST
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(
array(
'action' => 'GetClients',
'username' => 'myUsername',
'password' => 'myPassword',
'responsetype' => 'json')
)
);
$response = curl_exec($ch);
curl_close($ch);
// Decode response
$jsonData = json_decode($response, true);
// Dump array structure for inspection
//var_dump($jsonData);
?>