Cannot get access token using PHP and cURL

323 views
Skip to first unread message

James Drummond

unread,
Nov 30, 2013, 11:32:53 AM11/30/13
to mailchimp-...@googlegroups.com
Hi guys,

I'm trying to let users give my application the ability to view their lists and subscribe emails from my system to the list they specify. My application is an online booking system so it's very useful for my users to be able to add their customers to their mailing lists.

I have read the documentation quite thoroughly but cannot manage to get an access token with which to call the API.

I have setup the oauth side of things: I receive the 'code' token from https://login.mailchimp.com/oauth2/authorize no problem.

But that's where I get completely stuck. I am trying to make a PHP cURL call to https://login.mailchimp.com/oauth2/token with parameters:

$fields = array(
            'grant_type' => 'authorization_code',
            'client_id' => MAIL_CHIMP_CLIENT_ID,
            'client_secret' => MAIL_CHIMP_CLIENT_SECRET,
            'code' => $code,
            'redirect_URI' => urlencode(MAIL_CHIMP_REDIRECT_URI)
        );

This is supposed to return the access_token.

I'm stumped! Mostly I get gibberish in return. Does anyone have an example of making this call in PHP successfully (or an indication of the correct settings for cURL).

Any help is much appreciated!

James

Leonard Pan

unread,
Feb 13, 2014, 2:35:14 AM2/13/14
to mailchimp-...@googlegroups.com
Hi Drummond,

You should not encode the redirect url in this case.
Just have a try, it works on my machine.
Reply all
Reply to author
Forward
0 new messages