request_successful = false / Unknown error #147

Open
impressivewebs opened this Issue Nov 19, 2016 · 12 comments

Projects

None yet

6 participants

@impressivewebs

Hey @drewm, thanks for this script, it's certainly helped. Up until now I've had no problems using the script to display subscriber counts with the old version, compatible with MailChimp's pre-v3 API. However, I cannot get the new version (for MailChimp 3) to work.

After I include MailChimp.php, I'm doing the following:

use \DrewM\MailChimp\MailChimp;
$MailChimp = new MailChimp('xxxxxxxxxxxxxxxxxxxxxxxxxx-us5');
$result = $MailChimp->get('lists');

If I try to echo/print the $result variable, I get nothing. If I var_dump it, I get bool(false). If I var_dump($MailChimp), I get the following:

object(DrewM\MailChimp\MailChimp)#1 (7) { ["api_key":"DrewM\MailChimp\MailChimp":private]=> string(36) "xxxxxxxxxxxxxxxxxxxxxxxxxx-us5" ["api_endpoint":"DrewM\MailChimp\MailChimp":private]=> string(33) "https://us5.api.mailchimp.com/3.0" ["verify_ssl"]=> bool(true) ["request_successful":"DrewM\MailChimp\MailChimp":private]=> bool(false) ["last_error":"DrewM\MailChimp\MailChimp":private]=> string(64) "Unknown error, call getLastResponse() to find out what happened." ["last_response":"DrewM\MailChimp\MailChimp":private]=> array(2) { ["headers"]=> array(20) { ["url"]=> string(40) "https://us5.api.mailchimp.com/3.0/lists?" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0.015) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) } ["body"]=> bool(false) } ["last_request":"DrewM\MailChimp\MailChimp":private]=> array(5) { ["method"]=> string(3) "get" ["path"]=> string(5) "lists" ["url"]=> string(39) "https://us5.api.mailchimp.com/3.0/lists" ["body"]=> string(0) "" ["timeout"]=> int(10) } }

And of course, note that I've removed my API key in the examples above. The API key is correct in my code, and I even generated a new one just to ensure I had it right.

Ultimately, I had to settle for this solution, which works perfectly. I have no idea what's preventing your script from working in my case. The PHP version I'm testing on is 5.3.1 and I've enabled cURL in php.ini, which I believe is required.

Any thoughts on what's going wrong?

@starflower

Same here

@walshy002000

Same issue here.

@Falcikas
Falcikas commented Dec 1, 2016

For me setting the :
public $verify_ssl = false;

in MailChimp.php worked I have no SSL sertificate set on my local machine.

@drewm
Owner
drewm commented Dec 21, 2016

Unknown error, call getLastResponse() to find out what happened.

Did you call getLastResponse() to find out what happened, @impressivewebs?

@drewm drewm added the question label Dec 21, 2016
@impressivewebs

@drewm I thought I tried it, but I don't really understand what I'm supposed to read when I use that. I didn't get anything out of that to help me debug it, if that's what you're asking. If you want, I can try again and see what it says. But IIRC, it didn't help me.

@impressivewebs

@drewm Ok, if I do:

var_dump($MailChimp->getLastResponse());

I get:

array(2) { ["headers"]=> array(20) { ["url"]=> string(40) "https://us5.api.mailchimp.com/3.0/lists?" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0.032) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) } ["body"]=> bool(false) }

I have no idea what I'm looking for in there.

@drewm
Owner
drewm commented Dec 21, 2016

That looks like an SSL problem with your server:

["ssl_verify_result"]=> int(0)

@impressivewebs

Oh... well, the server I'm testing on is my local machine, so that would explain that. Another user in this thread mentioned setting public $verify_ssl = false;, so I guess that's what's needed? Forgot to try that. Is it unsafe to use the script in a non-SSL environment or something?

@impressivewebs

Yeah, I just tried it and it seems to work fine now. I guess that's solved, but I suppose it would be good if the docs explained the problem, or else provided instructions to set that to false if necessary.

@impressivewebs

@drewm Ah ok... Sorry, my bad. I guess I hadn't read the docs since the update. :( Thanks.

@lhviet
lhviet commented Dec 28, 2016

I set the verify_ssl to false and it works as normal (on localhost)
$MailChimp->verify_ssl = false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment