Problem with Creating Campaign In php

Occasional Contributor

Problem with Creating Campaign In php

Hi all,


I'm facing problem while creating a campaign. But i'm not getting any error code and also getting response code as 200. Please go through the below CC object and XML formats to figure out the problem. Please suggest me how can I create a campaign.


<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="">
  <link href="/ws/customers/slhemanthkumar/campaigns" rel="edit" />
  <title type="text">check1343743878</title>
    <name>Constant Contact</name>
  <content type="application/vnd.ctct+xml">
    <Campaign xmlns=""
                <ContactList id="">
                <link xmlns="" href="/ws/customers/slhemanthkumar/lists/1" rel="self" />
            <Email id="">
            <link xmlns="" href="/ws/customers/slhemanthkumar/settings/emailaddresses/1" rel="self" />
            <Email id="">
            <link xmlns="" href="/ws/customers/slhemanthkumar/settings/emailaddresses/1" rel="self" />
        <title type="text">Campaigns for customer: slhemanthkumar</title>
        <link href="campaigns" />
        <link href="campaigns" rel="self" />

cc Object
    [http_user_agent] => justphp 3.0
    [api_key] => 7*******************************5
    [api_username] => slhemanthkumar
    [api_password] => H*********6
    [api_url] =>
    [api_uri] => /ws/customers/slhemanthkumar/
    [last_error] =>
    [action_type] => ACTION_BY_CUSTOMER
    [list_meta_data] =>
    [member_meta_data] =>
    [http_host] =>
    [http_port] =>
    [http_url_bits] =>
    [http_request_timeout] => 120
    [http_user] => 7*******************************5%slhemanthkumar
    [http_pass] => Hemanth@86
    [http_content_type] => application/atom+xml
    [http_default_content_type] => text/html
    [http_response_code] => 200
    [http_response] =>
    [http_response_body] => <?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="">
  <title type="text"></title>
  <link href="emailaddresses"></link>
  <link href="emailaddresses" rel="self"></link>
    <link href="/ws/customers/slhemanthkumar/settings/emailaddresses/1" rel="edit"></link>
    <title type="text"></title>
      <name>Constant Contact</name>
    <content type="application/vnd.ctct+xml">
      <Email xmlns="" id="">
    [http_request] =>
    [http_method] => get
    [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] => 9090
    [http_response_info] => Array
            [url] =>
            [content_type] => application/atom+xml;charset=UTF-8
            [http_code] => 200
            [header_size] => 409
            [request_size] => 433
            [filetime] => -1
            [ssl_verify_result] => 20
            [redirect_count] => 0
            [total_time] => 2.11
            [namelookup_time] => 0
            [connect_time] => 0.25
            [pretransfer_time] => 1.672
            [size_upload] => 0
            [size_download] => 1156
            [speed_download] => 547
            [speed_upload] => 0
            [download_content_length] => 1156
            [upload_content_length] => 0
            [starttransfer_time] => 2.11
            [redirect_time] => 0

    [http_response_error] =>
    [xml_encoding] => ISO-8859-1







Re: Problem with Creating Campaign In php

The request you're running, which is correctly returning a 200 OK, is actually a GET request for the verified email addresses (settings email addresses) for the account.  What we're returning, and you can see that in the responsebody, is all the verified addresses for the account in question.


To create the campaign, you have to use the createCampaign() method of the library once you have a completed Campaign object.  That will send a POST request to create a Campaign with all of the properties you selected.  You'll then receive either a 201 Created or a 4XX error with some response saying why we couldn't create it (I.E. 409 conflict because you used a duplicate name). 

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More