PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

MailChimp API Integration Failure - Missing datacenter ID?

s2Member Plugin. A Membership plugin for WordPress®.

MailChimp API Integration Failure - Missing datacenter ID?

Postby wiseeyesmedia » June 5th, 2011, 7:35 pm

I just upgrade to s2member & pro v110605. It looks like there is an issue with MailChimp API integration.

Specifically, s2member does not seems to properly decode the specific data center (dc as the MailChimp API calls it) associated with the MailChimp API Key. The specific host s2member should access when using MailChimp's API is dependent upon the data center associated with the account.

For example, API keys are in the format xxxxxxxxxxxxxxx-[dc_id] where dc_id could be "us1" or "us2" or "uk1" or "uk2".

Based on the data center of the API key, s2member needs to submit its API request to different hosts. For example, my data center in my API key is "us2", so my API requests need to go to:

http://us2.api.mailchimp.com/1.3/

According to s2member's MailChimp logs, all my requests are going to the host of "api.mailchimp.com". The logs show an API call as successful, but members are not actually added to my list due to the incorrect (or missing) data center.

See MailChimp API docs:
http://apidocs.mailchimp.com/rtfm/

See s2Member's MailChimp API Logs:
...
'api_email_type' => 'html',
'api_double_optin' => true,
'api_update_existing' => false,
'api_replace_interests' => true,
'api_send_welcome' => false,
'api_response' => 'OK',
'api_success' => true,
'api_properties' =>
NC_MCAPI::__set_state(array(
'version' => '1.3',
'errorMessage' => '',
'errorCode' => '',
'apiUrl' =>
array (
'scheme' => 'http',
'host' => 'api.mailchimp.com',
'path' => '/1.3/',
'query' => 'output=php',
),
'timeout' => 300,
'chunkSize' => 8192,
'api_key' => 'XXXXXXXXXXXXXXXXXXXXXX-us2',
'secure' => false,
)),


I would also suggest s2Member use SSL for the MailChimp API, where possible.
User avatar
wiseeyesmedia
Experienced User
Experienced User
 
Posts: 11
Joined: January 30, 2011

Re: MailChimp API Integration Failure - Missing datacenter I

Postby Cristián Lávaque » June 6th, 2011, 3:57 am

Thank you for reporting this! I'm letting Jason know so he takes a look. :)
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: MailChimp API Integration Failure - Missing datacenter I

Postby Jason Caldwell » June 6th, 2011, 4:58 pm

Thanks for reporting this important issue.
~ and thanks for the heads up Cristián.

Not to worry. What you're seeing in the log files, is a represenatation of the MCAPI object instance, and the "host" property respresents the base API host, before it is prefixed by the callServer() method, as shown below.
Code: Select all
    function callServer($method, $params) {
        $dc = "us1";
        if (strstr($this->api_key,"-")){
            list($key, $dc) = explode("-",$this->api_key,2);
            if (!$dc) $dc = "us1";
        }
        $host = $dc.".".$this->apiUrl["host"];
        $params["apikey"] = $this->api_key; 
* So the proper prefixing does occur, it's just not reflected this way in the logs.
@TODO: I'll see what we can do about this.
Done, starting with s2Member v110606+, a "prefix" will be recorded in the logs.



As for the SSL communication. I'll see if we can add a Filter for this. Until then, you can enable SSL communication with MailChimp by modifying this file, if you like:
/includes/classes/list-servers.inc.php, at line #91

Change this:
Code: Select all
$mcapi = new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"]); 

To this:
Code: Select all
$mcapi = new NC_MCAPI ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["mailchimp_api_key"], true); 

@TODO: Agreed. Make SSL the default, and provide a Filter to turn it off.
Done. This will be included in the next release of s2Member v110606+.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: MailChimp API Integration Failure - Missing datacenter I

Postby Jason Caldwell » June 6th, 2011, 5:03 pm

FYI: s2Member uses an API wrapper, provided by MailChimp, as seen here:
http://apidocs.mailchimp.com/downloads/#php ( we use the PHP wrapper )
/includes/xtnls/mailchimp/nc-mcapi.inc.php
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: MailChimp API Integration Failure - Missing datacenter I

Postby wiseeyesmedia » June 6th, 2011, 9:33 pm

Jason,

Thanks for the super-fast response and update! I wish all developers were as quick as you!

I'll have to look more in detail into my MailChimp issue. The weird thing is that S2Member's logs show everything going smoothly, but I do not see any API activity at MailChimp's site under Account ---> API Keys and Info.

I wonder if the issue could be related to using the new list "group" feature? I have verified that my list ID, group title and group name are all correct. I do wonder if there is an issue with how I configured the group, though. When I created the group title in MailChimp, their site provides an option form how the group signups should appear. I chose the radio button setup, where a user could only select one group. This is because my groups map 1:1 with my WP member levels.

I will try upgrading to the latest version of S2Member to see if that resolves the issue.
User avatar
wiseeyesmedia
Experienced User
Experienced User
 
Posts: 11
Joined: January 30, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 0 guests

cron