Jump to content
  • 0

Getting Null on getting clients


Rizwan

Question

3 answers to this question

Recommended Posts

  • 0

Im getting the same problem, just null values. 

I added the ip addres under the security tab to allow it to connect using the API.

This is my code.

Thanks in advance..

 

<?php
 

// API Connection Details
$whmcsUrl = "mysystemurl";


$api_identifier = "identifierhere";
$api_secret = "secrethere";
$api_accesskey = "Apiaccesshere";

// Set post values
$postfields = array(
    'identifier' => $api_identifier,
    'secret' => $api_secret,
    'accesskey' => $api_accesskey,
    'action' => 'GetTickets',
    'responsetype' => 'json',
);

// Call the API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $whmcsUrl . 'includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
$response = curl_exec($ch);
if (curl_error($ch)) {
    die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
  echo "Voy a decode entrando aqui error";
}
curl_close($ch);

//print_r($results);
// Decode response
$jsonData = json_decode($response, true);

// Dump array structure for inspection
var_dump($jsonData);
//echo $response;

//var_dump($response);


?>

Link to comment
Share on other sites

  • 0
On 9/14/2022 at 7:32 AM, Alexxxcfr said:

Im getting the same problem, just null values. 

I added the ip addres under the security tab to allow it to connect using the API.

This is my code.

Thanks in advance..

 

<?php
 

// API Connection Details
$whmcsUrl = "mysystemurl";


$api_identifier = "identifierhere";
$api_secret = "secrethere";
$api_accesskey = "Apiaccesshere";

// Set post values
$postfields = array(
    'identifier' => $api_identifier,
    'secret' => $api_secret,
    'accesskey' => $api_accesskey,
    'action' => 'GetTickets',
    'responsetype' => 'json',
);

// Call the API
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $whmcsUrl . 'includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields));
$response = curl_exec($ch);
if (curl_error($ch)) {
    die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch));
  echo "Voy a decode entrando aqui error";
}
curl_close($ch);

//print_r($results);
// Decode response
$jsonData = json_decode($response, true);

// Dump array structure for inspection
var_dump($jsonData);
//echo $response;

//var_dump($response);


?>

It looks like you are trying to use the WHMCS API to retrieve a list of tickets from your WHMCS installation. There could be a few reasons why you are getting null values in the response. Here are a few things you can try:

  1. Make sure you have entered the correct URL for your WHMCS installation in the $whmcsUrl variable. This should be the base URL for your WHMCS installation, including the http:// or https:// prefix, but not including the /includes/api.php part.

  2. Make sure you have entered the correct API identifier, secret, and access key in the $api_identifier, $api_secret, and $api_accesskey variables, respectively. These values can be found in the "API Credentials" section of the "Setup > General Settings > Security" page in the WHMCS admin area.

  3. Make sure the IP address of the server that you are running this script on is added to the list of allowed IP addresses in the "API IP Access Restriction" section of the "Setup > General Settings > Security" page in the WHMCS admin area.

  4. Make sure you are using the correct action name in the action parameter of your API request. In this case, you are using the GetTickets action, which should return a list of tickets. However, if you want to retrieve a specific ticket, you can use the GetTicket action and specify the ticketid parameter with the ID of the ticket you want to retrieve.

  5. Make sure you are using the correct response type in the responsetype parameter of your API request. In this case, you are using the json response type, which will return the response as a JSON-encoded string. If you want to receive the response as an array, you can use the array response type instead.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated