cancel
Showing results for 
Search instead for 
Did you mean: 

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="http://www.w3.org/2005/Atom">
  <link href="/ws/customers/slhemanthkumar/campaigns" rel="edit" />
  <id>http://api.constantcontact.com/ws/customers/slhemanthkumar/campaigns</id>
  <title type="text">check1343743878</title>
  <updated>2009-10-19T18:34:53.105Z</updated>
  <author>
    <name>Constant Contact</name>
  </author>
  <content type="application/vnd.ctct+xml">
    <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/"
id="http://api.constantcontact.com/ws/customers/slhemanthkumar/campaigns/1100546096289">
      <Name>check1343743878</Name>
      <Status>Draft</Status>
      <Date>2009-10-19T18:34:53.105Z</Date>
<Subject>check</Subject>
<FromName>check</FromName>
<ViewAsWebpage>NO</ViewAsWebpage>
<ViewAsWebpageLinkText></ViewAsWebpageLinkText>
<ViewAsWebpageText></ViewAsWebpageText>
<PermissionReminder>NO</PermissionReminder>
<PermissionReminderText></PermissionReminderText>
<GreetingSalutation>Dear</GreetingSalutation>
<GreetingName>FirstName</GreetingName>
<GreetingString>Greetings!</GreetingString>
<OrganizationName>check</OrganizationName>
<IncludeForwardEmail>NO</IncludeForwardEmail>
<ForwardEmailLinkText></ForwardEmailLinkText>
<IncludeSubscribeLink>NO</IncludeSubscribeLink>
<SubscribeLinkText></SubscribeLinkText>
<EmailContentFormat>HTML</EmailContentFormat>
<EmailContent>&lt;html>&lt;body>hemanth&lt;/body>&lt;/html></EmailContent>
<EmailTextContent>&lt;Text>hello&lt;/Text></EmailTextContent>
<ContactLists>
                <ContactList id="http://api.constantcontact.com/ws/customers/slhemanthkumar/lists/1">
                <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/slhemanthkumar/lists/1" rel="self" />
                </ContactList>
              </ContactLists>
            <FromEmail>
            <Email id="http://api.constantcontact.com/ws/customers/slhemanthkumar/settings/emailaddresses/1">
            <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/slhemanthkumar/settings/emailaddresses/1" rel="self" />
            </Email>
            <EmailAddress>kumar.hemanth@tcs.com</EmailAddress>
            </FromEmail>
            <ReplyToEmail>
            <Email id="http://api.constantcontact.com/ws/customers/slhemanthkumar/settings/emailaddresses/1">
            <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/slhemanthkumar/settings/emailaddresses/1" rel="self" />
            </Email>
            <EmailAddress>kumar.hemanth@tcs.com</EmailAddress>
            </ReplyToEmail>
            
    </Campaign>
    </content>
    <source>
        <id>http://api.constantcontact.com/ws/customers/slhemanthkumar/campaigns</id>
        <title type="text">Campaigns for customer: slhemanthkumar</title>
        <link href="campaigns" />
        <link href="campaigns" rel="self" />
        <author>
            <name>slhemanthkumar</name>
        </author>
        <updated>2009-10-19T19:36:12.622Z</updated>
    </source>
</entry>

cc Object
(
    [http_user_agent] => justphp 3.0
    [api_key] => 7*******************************5
    [api_username] => slhemanthkumar
    [api_password] => H*********6
    [api_url] => https://api.constantcontact.com/ws/customers/slhemanthkumar/
    [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="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/slhemanthkumar/settings/emailaddresses</id>
  <title type="text"></title>
  <link href="emailaddresses"></link>
  <link href="emailaddresses" rel="self"></link>
  <author>
    <name>slhemanthkumar</name>
  </author>
  <updated>2012-07-31T14:11:30.466Z</updated>
  <entry>
    <link href="/ws/customers/slhemanthkumar/settings/emailaddresses/1" rel="edit"></link>
    <id>http://api.constantcontact.com/ws/customers/slhemanthkumar/settings/emailaddresses/1</id>
    <title type="text">kumar.hemanth@tcs.com</title>
    <updated>2012-07-24T08:13:09.966Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/slhemanthkumar/settings/emailaddresses/1">
        <EmailAddress>kumar.hemanth@tcs.com</EmailAddress>
        <Status>Verified</Status>
        <VerifiedTime>2012-07-24T08:13:09.966Z</VerifiedTime>
      </Email>
    </content>
  </entry>
</feed>
    [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] => secure-proxy-pdmz.qualcomm.com
    [proxy_port] => 9090
    [http_response_info] => Array
        (
            [url] => https://api.constantcontact.com/ws/customers/slhemanthkumar/settings/emailaddresses
            [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
)

Thanks,

Hemanth

 

 

 

1 REPLY 1
Moderator

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