We have an issue with the cURL code that comes along with the documentation.
We are trying to catch if an email has been bounced.
We have setted it up with the curl functions in PHP, but it only returns; authorization required
`//Find bounce report.
$curl = curl_init();
curl_setopt_array($curl,
array(
CURLOPT_RETURNTRANSFER => 1,
CURLAUTH_ANY,
CURLOPT_URL => 'https://api.sendgrid.com/v3/suppression/bounces/'.$bouncemail.'/',
CURLOPT_HTTPHEADER => 'Authorization: Bearer '.$key
));
$bounce_report = curl_exec($curl);
$bounce_report_decoded = json_decode($bounce_report, true); //Turn the curl result into a json document, and then convert it to an assoc array.
// close curl resource to free up system resources
curl_close($ch);`
We feel like we have tried everything, but we cant seem to figure it out. Not sure if this is a bug or not, but we have used the official documentation.
Kind regards
Hello @rainman0607,
Could you please provide a link to where you saw this documentation?
Thanks!
With Best Regards,
Elmer
@thinkingserious Sure!
https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html
Do you get the same if you change CURLOPT_HTTPHEADER to use an array?
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
CURLAUTH_ANY,
CURLOPT_URL => 'https://api.sendgrid.com/v3/suppression/bounces/'.$bouncemail,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer '.$key
]
]);
Hello @rainman0607,
It sounds like there is a API key issue. In that case I would contact our support team so that they can help debug your account.
Otherwise, if you choose to use our PHP SDK, here is the documentation for that call.
Thank you!
With Best Regards,
Elmer