We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Failing to add multiple contacts at a time using Constant contact drupal module

HemanthK6
Participant

Failing to add multiple contacts at a time using Constant contact drupal module

Hi All,

 

I'm using the drupal constant contact modiule and i tried to add multiple contacts at a time, but nothing is happening.

 

Below are the params I'm passing to the function.

 

$params  = Array ( [activityType] => SV_ADD [data] => EmailAddress {REDACTED}/, {REDACTED}/, [lists] => Array ( [0] => http://api.constantcontact.com/ws/customers/{REDACTED}//lists/2 ) )

 

$this->http_set_content_type('application/x-www-form-urlencoded');

$xml = $this->load_url("activities", 'post', $params, 201);

 

if I try to print the $this object, getting the below code.

 

cc Object
(
    [http_user_agent] => justphp 3.0
    [api_key] => {REDACTED}
    [api_username] => {REDACTED}/
    [api_password] => {REDACTED}/
    [api_url] => https://api.constantcontact.com/ws/customers/{REDACTED}//
    [api_uri] => /ws/customers/{REDACTED}//
    [last_error] => Invalid status code 400
    [action_type] => ACTION_BY_CONTACT
    [list_meta_data] =>
    [member_meta_data] =>
    [http_host] =>
    [http_port] =>
    [http_url_bits] =>
    [http_request_timeout] => 120
    [http_user] => {REDACTED}/
    [http_pass] => {REDACTED}/
    [http_content_type] => application/x-www-form-urlencoded
    [http_default_content_type] => text/html
    [http_response_code] => 400
    [http_response] =>
    [http_response_body] =>
    [http_request] =>
    [http_method] => post
    [http_linebreak] =>

    [http_request_headers] => Array
        (
        )

    [http_response_headers] => Array
        (
        )

    [xml_known_encodings] => Array
        (
            [0] => UTF-8
            [1] => US-ASCII
            [2] => ISO-8859-1
        )

    [proxy_server] =>
    [proxy_port] => 8080
    [http_response_info] => Array
        (
            [url] => https://api.constantcontact.com/ws/customers/{REDACTED}//activities
            [content_type] =>
            [http_code] => 400
            [header_size] => 25
            [request_size] => 377
            [filetime] => -1
            [ssl_verify_result] => 20
            [redirect_count] => 0
            [total_time] => 0.422
            [namelookup_time] => 0
            [connect_time] => 0
            [pretransfer_time] => 0.25
            [size_upload] => 400
            [size_download] => 0
            [speed_download] => 0
            [speed_upload] => 947
            [download_content_length] => -1
            [upload_content_length] => 400
            [starttransfer_time] => 0.328
            [redirect_time] => 0
        )

    [http_response_error] => The requested URL returned error: 400
    [xml_encoding] => ISO-8859-1
)


 

but $xml is returning null. Can you please help me how to add multiple contacts to the constant contact.

 

Thanks,

Hemanth

1 REPLY 1
DaveBerard
Moderator

Sorry for the error you're seeing.  I'm not overly familiar with how the Drupal module works, it was developed by another company and is an open source project now.  It's hard for me to trouble shoot the exact cause of your 400 error without seeing the raw request being send, but the likely cause is that the data is not being encoded correctly.  I would try URL encoding the List ID you're putting in the array as well as the email address you're adding to data.  If that doesn't work, I'd also try using just the ID number at the end of the list ID in the array instead of the full list ID value.

 

FYI - I also redacted all of your personal informaton. However, since your post was up for some time with your username and password exposed, I would recommend changing both of those immediately to protect your account and your data.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

View API documentation, code samples, get your API key.

Visit Page