Take the 2-minute tour ×

I am trying to get the list of contacts for my account in iContact using a php script. I can get the contact list using RestClient by entering the set of headers, the url and pressing go so I'm pretty sure my headers and url are correct. iContact provides example code for this task however when I run that (with my account and ap details) I get the same response as when I run the following code:


    $Headers = array(
                "Accept: text/xml",
                "Content-Type: text/xml",
                "API-Version: 2.2",
                "API-AppId: grBddgWuirhAYT41K6gvrvRGaUGJFVQL",
                "API-Username: <removed>",
                "API-Password: <removed>");

    $Url = "https://app.sandbox.icontact.com/icp/a/412608/c/123920/contacts";

    $Handle    = curl_init();
        die("Could not create a cURL handle.");

    curl_setopt($Handle, CURLOPT_URL, $Url);
    curl_setopt($Handle, CURLOPT_HTTPHEADER, $Headers);
    curl_setopt($Handle, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110303 Ubuntu/10.04 (lucid) Firefox/3.6.15");

    curl_setopt($Handle, CURLOPT_RETURNTRANSFER, true);
    $Response = curl_exec($Handle);

    $iCode = curl_getinfo($Handle);
    echo "Response: <br />";
    echo "Code: <br />";


This gives the out put:


Array ( [url] => https://app.sandbox.icontact.com/icp/a/412608/c/123920/contacts [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.094 [namelookup_time] => 0 [connect_time] => 0.094 [pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0 [redirect_time] => 0 ) 

From what I understand of curl (which isn't very much at the moment) the http_code should be 200 and the xml should be in $Response.

Could anyone point out what I'm doing wrong please?

The iContact examples are available here: http://developer.icontact.com/documentation/code-library-zip-file/

I am trying to do what get_contacts.php should do.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The problem wasn't with the code, that was fine. I couldn't run it and get a response from my localhost though, had to use a public server.

share|improve this answer

Your Answer


