0

I am using PHP's CURL function to return all unsubscribed emails in my domain using MailGun. I tried the following code:

function get_unsubscriptions() {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, 'api:key-[key removed]');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_URL, 'https://api.mailgun.net/v3/[domain removed]/unsubscriptions');

    $result = curl_exec($ch);

    curl_close($ch);
    return $result;
}

But it only returns the following:

Mailgun Magnificent API

What am I doing wrong?

David
  • 5,877
  • 3
  • 23
  • 40
  • Nothing else to the error like "Unexpected token"? Have you considered looking at their SDK? Also: [Php - Debugging Curl](https://stackoverflow.com/questions/3757071/php-debugging-curl) – ficuscr Jul 20 '18 at 16:18
  • That's the thing, it isn't an error. The message is what is returned from `$result`. I've looked at their documentation but it only relates to their API (as opposed to using cURL), however everything looks like it matches up. – David Jul 20 '18 at 16:19
  • 1
    Is it really `unsubscriptions`? Pretty sure that isn't a word. Maybe `unsubscribes`? – ficuscr Jul 20 '18 at 16:26
  • 2
    The endpoint is `unsubscribes` not `unsubscriptions`. [See Here](https://documentation.mailgun.com/en/latest/api-suppressions.html#view-all-unsubscribes). Voting to close as a typo. – Patrick Q Jul 20 '18 at 16:26
  • That was it, gosh I'm dumb... – David Jul 20 '18 at 16:28
  • They could give you a better error message honestly. – ficuscr Jul 20 '18 at 16:28

0 Answers0