Open ashok-groovy opened 7 years ago
Hello, I already have the same problem but i resolve with this line
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
i think is a problem from the ssl url of freshdesk api but i hope that works for you too, for now is work for me
Ticket created successfully, the response is given below Response Headers are HTTP/1.1 201 Created Cache-Control: no-cache, no-store, max-age=0, must-revalidate Content-Type: application/json; charset=utf-8 Date: Mon, 30 Jan 2017 23:23:12 GMT Expires: Wed, 13 Oct 2010 00:00:00 UTC Location: https://bnnprueba.freshdesk.com/api/v2/tickets/6 Pragma: no-cache Status: 201 Created X-Freshdesk-API-Version: latest=v2; requested=v2 X-Rack-Cache: invalidate, pass X-RateLimit-Remaining: 4996 X-RateLimit-Total: 5000 X-RateLimit-Used-CurrentRequest: 1 X-Request-Id: 1849927ed3fd6546dd2b46e04b4194b2 Content-Length: 705 Connection: keep-alive Response Body {"cc_emails":["ram@freshdesk.com","diana@freshdesk.com"],"fwd_emails":[],"reply_cc_emails":["ram@freshdesk.com","diana@freshdesk.com"],"fr_escalated":false,"spam":false,"email_config_id":null,"group_id":null,"priority":1,"requester_id":23000142027,"responder_id":null,"source":2,"company_id":null,"status":2,"subject":"Support needed..","to_emails":null,"product_id":null,"id":6,"type":null,"due_by":"2017-02-02T22:00:00Z","fr_due_by":"2017-01-31T22:00:00Z","is_escalated":false,"description":" Some details on the issue ... ","description_text":"Some details on the issue ...","custom_fields":{},"created_at":"2017-01-30T23:23:12Z","updated_at":"2017-01-30T23:23:12Z","tags":[],"attachments":[]}
I am experiencing the same issue.
the code that I am using is directly from this site, with the addition of the line mentioned above
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
my code is a s follows
//curl -v -u ME:MYPASSWORD -X GET 'https://MYDOMAIN.freshdesk.com/api/v2/contacts'
//Display all errors
do {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
}while(false);
$api_key = "MYAPIKEYGOESHERE";
$password = "x";
$yourdomain = "MYDOMAIN";
$url = "https://$yourdomain.freshdesk.com/api/v2/contacts";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
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);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($server_output, 0, $header_size);
$response = substr($server_output, $header_size);
if($info['http_code'] == 200) {
echo "Contacts fetched successfully, the response is given below \n";
echo "Response Headers are \n";
echo $headers."\n";
echo "Response Body \n";
echo "$response \n";
} else {
if($info['http_code'] == 404) {
echo "Error, Please check the end point \n";
} else {
echo "Error, HTTP Status Code : " . $info['http_code'] . "\n";
echo "Headers are ".$headers;
echo "Response are ".$response;
}
}
var_dump($server_output);
curl_close($ch);
I am using PHP 5.3
With a previous version of my php script i was receiving the error
Curl failed with error #35: Unknown SSL protocol error in connection to'
i tried curl_setopt($ch, CURLOPT_SSLVERSION, 6)
for TLS 1.2 but it did not seem to work.
When i ran the curl command sited in the API reference pages from a terminal on ubuntu on a different machine, it worked perfectly. I am suspicious of the older version of PHP that we are using, however that is beyond my control.
This issue is not about the PHP version but the OpenSSL version you are running, the minimal version to make this work is OpenSSL 1.0.2 (LTS) which has TLS1.1 and TLS1.2. The server you are using is probably stuck on 0.9.8 which only has TLS1.
Error, HTTP Status Code : 0 Headers are Response are
Array ( [url] => https://groovy.freshdesk.com/api/v2/tickets [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 1 [redirect_count] => 0 [total_time] => 0.437 [namelookup_time] => 0.016 [connect_time] => 0.234 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 [redirect_url] => [primary_ip] => 54.175.248.244 [certinfo] => Array ( )
)