swt83 / php-mailchimp

A PHP library for working w/ the Mailchimp API.
MIT License
18 stars 4 forks source link

Mailchim integration does not work #1

Closed vaske closed 11 years ago

vaske commented 11 years ago

Do you still support this? I can't manage it to work, constantly getting bool false as a response.

swt83 commented 11 years ago

Check to make sure you have the config setup properly. Copy the provided sample config to your application/config/mailchimp.php location and input your API information.

alexleonard commented 11 years ago

Hmm, I'm getting and error when trying to run the artisan command

php artisan mailchimp::lists

Notice: Undefined offset: 1 in D:\path\to\bundles\mailchimp\libraries\mailchimp.php on line 20

My API key looks correct to me and ends with "-us6"

I am assuming the error is being thrown by:

    // determine endpoint
    list($ignore, $server) = explode('-', $api_key);
    $endpoint = 'https://'.$server.'.api.mailchimp.com/1.3/?method='.self::camelcase($method);

My bundles/mailchimp/config/mailchimp.php reads (api key obscured)


return array(

    'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-us6',

);```
vaske commented 11 years ago

What is strange I compared MailChimp sample php API what they provide on their website, and that one adds new emails on my account if I try to use it via this implementation, I don't get any error but no new email on my lists on MailChimp.

I place config on right place etc..it's not an issue..

alexleonard commented 11 years ago

I've just written a pull request to alter mailchimp/libraries/mailchimp.php line 17 to

    $api_key = Config::get('mailchimp::mailchimp.api_key');

This has fixed my first error - now to see if subscribers are being added :)

alexleonard commented 11 years ago

@vaske Are you encountering this error on localhost?

I have tried php artisan mailchimp::lists on localhost and server and it works on server testing env, but not on localhost.

I'm guessing the issue is going to be the same issue I had with Mandrill:

https://github.com/MichMich/laravel-mandrill/issues/7

alexleonard commented 11 years ago

Just added cacert.pem to my mailchimp libraries folder and added

    if (Request::env() == 'local')
    {
        curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__)."/cacert.pem");
    }

Now getting true response from list_subscribe.

vaske commented 11 years ago

@alexleonard yes on localhost...I'm still using laravel 3, but plan to upgrade to laravel 4.

alexleonard commented 11 years ago

@vaske cool - I think if you follow: https://github.com/MichMich/laravel-mandrill/issues/7 and make sure to change Config::get('mailchimp.api_key'.. to Config::get('mailchimp::mailchimp.api_key'... you should be good.

vaske commented 11 years ago

@alexleonard that works thanks and sorry for late response, you may close this one...

swt83 commented 11 years ago

The library is written specifically to pull the config from application/config/mailchimp.php, with you copying the sample config to that location. The reason for this is so updates to the package (git pull origin master) can be applied w/out messing up your config settings.

Regarding the localhost issue, I run this package fine on my development machine with no problems. I assume this issue is SSL related but not sure what the particular is.

alexleonard commented 11 years ago

Ahhh, so the idea is to copy the config out of the bundle and into your local config - I totally hadn't twigged that! It's the littlest things that one trips over...!

vaske commented 11 years ago

Guys I did that I copy config under application/config/mailchimp.php and still had that issue until I copy those SSL things...

alexleonard commented 11 years ago

@vaske I haven't yet worked out how to force curl requests in Windows to not require the cacert.pem file but you can probably bypass it by doing:

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

in library/mailchimp.php

vaske commented 11 years ago

Suddenly I start working when I add those SSL files, Linux worked before now windows as well, hooray!

alexleonard commented 11 years ago

Brilliant, glad you got it going :) On 26 Jun 2013 18:14, "Milan Vasic" notifications@github.com wrote:

Suddenly I start working when I add those SSL files, Linux worked before now windows as well, hooray!

— Reply to this email directly or view it on GitHubhttps://github.com/swt83/laravel-mailchimp/issues/1#issuecomment-20040186 .

vaske commented 11 years ago

Me to ;)