Sendgrid-php: SendGrid Bounce API (Authorization Required)

Created on 2 Oct 2018  路  4Comments  路  Source: sendgrid/sendgrid-php

Issue Summary

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

The code

`//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);`

More:

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.

Technical details:

  • sendgrid-php Version: master (latest)
  • PHP Version: 7.1 (as of May 17, 2018)

Kind regards

unknown or a waiting for feedback question

All 4 comments

Hello @rainman0607,

Could you please provide a link to where you saw this documentation?

Thanks!

With Best Regards,

Elmer

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamanupammaity picture iamanupammaity  路  4Comments

elshafey picture elshafey  路  4Comments

jverlee picture jverlee  路  4Comments

peluprvi picture peluprvi  路  5Comments

KayakinKoder picture KayakinKoder  路  5Comments