benbowler / codeigniter-mailchimp-api-v2

A Mailchimp API v2 wrapper for Codeigniter based on great work by Drew McLellan
34 stars 18 forks source link

Mailchimp configs not loading #1

Open smokinjoe opened 10 years ago

smokinjoe commented 10 years ago

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');
benbowler commented 10 years ago

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

vbujak commented 10 years ago

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);
benbowler commented 10 years ago

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!

tcgumus commented 9 years ago

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.

momon commented 9 years ago

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