Can't connect with API to my freshdesk Account with PHP

  • 5 October 2018
  • 0 replies
  • 24 views

Hi,

I'm using a PHP code to try to fetsh my tickets. Sample of code used :

 

$api_key = "xxxxxxxxxxxxxxx";
$password = "x";
$yourdomain = "yyyyyyyyyy";
// Return the tickets that are new or opend & assigned to you
// If you want to fetch all tickets remove the filter query param
$url = "https://$yourdomain.freshdesk.com/api/v2/tickets";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$api_key:$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec($ch);
$info = curl_getinfo($ch);
//var_dump($info);exit;
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);

 when i var_dump $info i can see that my code add HTTP and try to connect to HTTP://https://domain.freshdesk....


How can i resolve this problem ? thanks.


This topic has been closed for comments