CakePHP-Mailchimp-datasource 1.3 Read Method

If anyone’s still using CakePHP v1.3 of this brilliant datasource which allows you to treat data on subscribers in MailChimp as if they were in a local model, I had to make a few changes to make it work with v1.3 of the MailChimp API.

 
function read($model, $queryData = array()) {
 $url = $this->buildUrl('listMemberInfo', $queryData['conditions']['emailaddress']);
 $response = json_decode($this->connection->get($url), true);
 if(isset($response['errors'])&&$response['errors']>0) { //this is how errors are indicated
 return false;
 }
 return $response['data']; //allows find('first') to return $response['data'][0]
 }

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.