1

I trying to save the record of the subscriber to mail chimp in php, but i'm getting this error of which i don't understand:

fsockopen(): php_network_getaddresses: getaddrinfo failed: No such host is known.

I'm using MCAPI class version 1.3

here is my code to save:

    $apikey='d9750fc48519551e22e789c1gthy050a5-fd7'; // Enter your API key
    $api = new MCAPI($apikey);
    $retval = $api->lists();


    $listid='d395e7afr4'; // Enter list Id here

    $fname = $this->stepdata['yourName'];
    $lname = $this->stepdata['yourName'];
    $email = $this->stepdata['yourEmail'];


    // By default this sends a confirmation email - you will not see new          members
    // until the link contained in it is clicked!

    $merge_vars = array('FNAME' => $fname, 'LNAME' => $lname, 'EMAIL' => $email);
    //listSubscribe'=>array("id","email_address","merge_vars","email_type","double_optin","update_existing","replace_interests","send_welcome")
    if($api->listSubscribe($listid, $email, $merge_vars, $email_type='html', $double_optin=false, $update_existing=false, $replace_interests=false, $send_welcome=true ) === true) {

    }

This is where the error is pointing at on MCAPI class

   ob_start();
    if ($this->secure){
        $sock = fsockopen("ssl://".$host, 443, $errno, $errstr, 30);
    } else {
        $sock = fsockopen($host, 80, $errno, $errstr, 30);
    }

Thanks

3

1 Answer 1

0

If that's a real API Key, you should definitely disable the API Key and generate a new one, but that actually helps answer this question in this case.

The MailChimp libraries use the second part of the API Key to determine which datacenter to connect to. In this case, the library is going to interpret that as 'fd7', and will try to connect to fd7.api.mailchimp.com, which isn't a valid MailChimp datacenter.

I'd re-copy your API key from your dashboard and make sure that the last part looks like 'usX' where X is some number between 1-10.

Not the answer you're looking for? Browse other questions tagged or ask your own question.