Curl_error: couldn't connect to host. Using API v3 PHP Wrapper


I'm trying to use the new V3 API to add a subscriber to one of my lists, I have the main API, and list API etc, and using your subscriber add test when running im getting this error:

Fatal error: Error making request with curl_error: couldn't connect to host in /srv/ on line 132

cURL is installed, and OpenSSL isn't. However even trying to force your API to use HTTP by using this:

$wrap = new CS_REST_Subscribers('92aa94463366f16e74a3a718b67209fb', '207ff9948923cf26ad96b4f1e0a6fff7', 'http');

Still doesn't work.

The full subscriber code is:


    $row->other_email = '';
    $row->billing_name_first = 'Ben';
    $row->billing_name_last = 'Smith';
    $wrap = new CS_REST_Subscribers('92aa94463366f16e74a3a718b67209fb', '207ff9948923cf26ad96b4f1e0a6fff7', 'http');
    $result = $wrap->add(array(
        'EmailAddress' => $row->other_email,
        'Name' => $row->billing_name_first.' '.$row->billing_name_last
    echo "Result of POST /api/v3/subscribers/{list id}.{format}\n<br />";
    if($result->was_successful()) {
        echo "Subscribed with code ".$result->http_status_code;
    } else {
        echo 'Failed with code '.$result->http_status_code."\n<br /><pre>";
        echo '</pre>';

Any ideas?


Carissa Carissa, 5 years ago

Hi Ben,

Thanks for posting here. I wanted to let you know we also received your email sent in to support. I've forwarded it to a developer who can get back to you. Thanks!

Campaign Monitor

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free