简体   繁体   中英

“Empty” GET request using PHP and CURL

I'm down to step 5 of the OAuth flow for Mailchimp's API. Documentation I'm sending the right token (I've tested it in their playground) and I'm getting back invalid token errors

Here's what I've got:

  $headr3 = array();
$headr3[] = 'OAuth 1476f8c8xxxxxxxxxxxxxxxx';
$headr3[] = 'User-Agent: oauth2-draft-v10';
$headr3[] = 'Host: login.mailchimp.com';
$headr3[] = 'Accept: application/json';
$url3 = 'https://login.mailchimp.com/oauth2/metadata';

$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1,
   CURLOPT_HTTPHEADER=> $headr3,
    CURLOPT_URL => $url3,
    CURLOPT_ENCODING => ''
));

$resp = curl_exec($curl);
$dec_respo = (json_decode($resp, true));
var_dump($dec_respo); 

I'm thinking that the way I'm sending the data is incorrect, but not sure what the problem might be.

This ended up being an error on my part.

I had this:

$headr3[] = 'OAuth 1476f8c8xxxxxxxxxxxxxxxx';

But should have had this:

$headr3[] = 'Authorization: OAuth 1476f8c8xxxxxxxxxxxxxxxx';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM