codeigniter-mailchimp-api-v2 icon indicating copy to clipboard operation
codeigniter-mailchimp-api-v2 copied to clipboard

Mailchimp configs not loading

Open smokinjoe opened this issue 11 years ago • 5 comments

I had to change the __construct() in mailchimp_library.php to be:

$this->ci =& get_instance();
$this->ci->load->config('mailchimp', TRUE);
$this->api_key = $this->ci->config->item('api_key', 'mailchimp');
$this->api_endpoint = $this->ci->config->item('api_endpoint', 'mailchimp');

smokinjoe avatar Nov 20 '13 23:11 smokinjoe

Thanks for taking to the time to look at that. Is it completely working for you now?

benbowler avatar Nov 28 '13 15:11 benbowler

here is correct __construct:

$this->ci =& get_instance();
$this->ci->load->config('mailchimp', TRUE);
$this->api_key = $this->ci->config->item('api_key', 'mailchimp');
$this->api_endpoint = $this->ci->config->item('api_endpoint', 'mailchimp');

list(, $datacentre) = explode('-', $this->api_key);
$this->api_endpoint = str_replace('<dc>', $datacentre, $this->api_endpoint);

vbujak avatar Nov 29 '13 12:11 vbujak

Great can you submit a pull request? I'll ad it in. If you're not bothered about the ref back I'll just build it in and commit myself.

I'm back using this again!

benbowler avatar Feb 17 '14 16:02 benbowler

Also we need to call the function in lowercase like this.

    $this->load->library('mailchimp_library');
    $lists = $this->mailchimp_library->call('lists/list');

This solved my problem.

tcgumus avatar May 07 '15 15:05 tcgumus

For those having issues with this, the problem is rather simple... in the construct there is a line that is actually breaking things. Specifically:

$this->api_endpoint = $this->ci->config->item('api_endpoint', 'mailchimp');

This is overwriting $this->api_endpoint from the value set on the class: private $api_endpoint = 'https://.api.mailchimp.com/2.0/';

So by the time you get to $this->api_endpoint = str_replace('', $datacentre, $this->api_endpoint); the value that it is expecting is no longer there.

The fix is simply to comment out or remove the line:

$this->api_endpoint = $this->ci->config->item('api_endpoint', 'mailchimp');

Cheers, Jose R. Lopez

momon avatar Aug 06 '15 00:08 momon