tidanlemire | Posts: 4

Get PDF with curl returns nothing

0 votes
I'm trying to get the pdf file via php using curl but I get nothing returned. When I do the same in Postman I get the PDF file. Here is my php code
$headers = array('Content-Type: application/json', 'Authorization: Basic '.$ApiKey, 'Accept: application/pdf', 'Connection: Keep-Alive');
$url = 'https://apps.e-signlive.com/api' . '/packages/'.$packageId.'/documents/'.$documentid.'/pdf';
$ch = curl_init();
$timeout = 60;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
Can someone see something I missed? Thanks

mwilliams | Posts: 957

Reply to: Get PDF with curl returns nothing

0 votes
Try something like this to see what error comes back:
$data = curl_exec($ch);
		
$err = curl_error($ch);
curl_close($ch);
		
if ($err)
{
	print_r($err);
}
else
{
	echo $data;
};
Let me know.

tidanlemire | Posts: 4

Reply to: Get PDF with curl returns nothing

0 votes
Thank you for the help. The problem was with the SSL . Simply adding this line fixed the problem curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

mwilliams | Posts: 957

Reply to: Get PDF with curl returns nothing

0 votes
Great! Glad it's working! Thanks for updating the thread with your solution!

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off