{"id":239,"date":"2011-06-03T20:57:56","date_gmt":"2011-06-03T20:57:56","guid":{"rendered":"http:\/\/www.sitekickr.com\/blog\/?p=239"},"modified":"2011-06-03T20:58:48","modified_gmt":"2011-06-03T20:58:48","slug":"constant-contact-rest-api-new-subscriber","status":"publish","type":"post","link":"https:\/\/www.sitekickr.com\/blog\/constant-contact-rest-api-new-subscriber\/","title":{"rendered":"Constant Contact REST API &#8211; New Subscriber"},"content":{"rendered":"<p>This is not a typical post, but I just had to share as it took me a good afternoon of trial error to figure out how to add a new contact to a Constant Contact account using their REST API. Their documentation has many holes, but fortunately the API works well.<\/p>\n<p>After you&#39;ve authenticated, here&#39;s the XML required to add a new subscriber:<\/p>\n<p><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br \/>\n\t&lt;entry xmlns=&quot;http:\/\/www.w3.org\/2005\/Atom&quot;&gt;<br \/>\n\t&nbsp; &lt;link href=&quot;\/ws\/customers\/<em><strong>username<\/strong><\/em>\/contacts&quot; rel=&quot;edit&quot;&gt;&lt;\/link&gt;<br \/>\n\t&nbsp; &lt;id&gt;http:\/\/api.constantcontact.com:443\/ws\/customers\/<em><strong>username<\/strong><\/em>\/contacts&lt;\/id&gt;<br \/>\n\t&nbsp; &lt;title type=&quot;text&quot;&gt;Contact: <em><strong>email@address.com<\/strong><\/em>&lt;\/title&gt;<br \/>\n\t&nbsp; &lt;updated&gt;2011-02-27T18:48:00.760Z&lt;\/updated&gt;<br \/>\n\t&nbsp; &lt;author&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;name&gt;Constant Contact&lt;\/name&gt;<br \/>\n\t&nbsp; &lt;\/author&gt;<br \/>\n\t&nbsp; &lt;content type=&quot;application\/vnd.ctct+xml&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;Contact xmlns=&quot;http:\/\/ws.constantcontact.com\/ns\/1.0\/&quot; id=&quot;http:\/\/api.constantcontact.com:443\/ws\/customers\/<em><strong>username<\/strong><\/em>\/contacts&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Status&gt;Active&lt;\/Status&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;EmailAddress&gt;<em><strong>email@address.com<\/strong><\/em>&lt;\/EmailAddress&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OptInSource&gt;ACTION_BY_CUSTOMER&lt;\/OptInSource&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;EmailType&gt;HTML&lt;\/EmailType&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Name&gt;<em><strong>this doesn&#39;t seem to work - use firstname &amp; lastname instead<\/strong><\/em>&lt;\/Name&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;FirstName&gt;&lt;\/FirstName&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;MiddleName&gt;&lt;\/MiddleName&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;LastName&gt;&lt;\/LastName&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;JobTitle&gt;&lt;\/JobTitle&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CompanyName&gt;&lt;\/CompanyName&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;HomePhone&gt;&lt;\/HomePhone&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;WorkPhone&gt;&lt;\/WorkPhone&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Addr1&gt;&lt;\/Addr1&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Addr2&gt;&lt;\/Addr2&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Addr3&gt;&lt;\/Addr3&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;City&gt;&lt;\/City&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;StateCode&gt;&lt;\/StateCode&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;StateName&gt;&lt;\/StateName&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CountryCode&gt;&lt;\/CountryCode&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CountryName&gt;&lt;\/CountryName&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PostalCode&gt;&lt;\/PostalCode&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;SubPostalCode&gt;&lt;\/SubPostalCode&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Note&gt;&lt;\/Note&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField1&gt;&lt;\/CustomField1&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField2&gt;&lt;\/CustomField2&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField3&gt;&lt;\/CustomField3&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField4&gt;&lt;\/CustomField4&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField5&gt;&lt;\/CustomField5&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField6&gt;&lt;\/CustomField6&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField7&gt;&lt;\/CustomField7&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField8&gt;&lt;\/CustomField8&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField9&gt;&lt;\/CustomField9&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField10&gt;&lt;\/CustomField10&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField11&gt;&lt;\/CustomField11&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField12&gt;&lt;\/CustomField12&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField13&gt;&lt;\/CustomField13&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField14&gt;&lt;\/CustomField14&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CustomField15&gt;&lt;\/CustomField15&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ContactLists&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;ContactList id=&quot;http:\/\/api.constantcontact.com:443\/ws\/customers\/<em><strong>username<\/strong><\/em>\/lists\/2&quot;&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;link xmlns=&quot;http:\/\/www.w3.org\/2005\/Atom&quot; href=&quot;\/ws\/customers\/<em><strong>username<\/strong><\/em>\/lists\/2&quot; rel=&quot;self&quot;&gt;&lt;\/link&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OptInSource&gt;ACTION_BY_CONTACT&lt;\/OptInSource&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;OptInTime&gt;2011-02-27T18:48:00.810Z&lt;\/OptInTime&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/ContactList&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/ContactLists&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Confirmed&gt;true&lt;\/Confirmed&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;InsertTime&gt;2011-02-27T18:48:00.760Z&lt;\/InsertTime&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;LastUpdateTime&gt;2011-02-27T18:48:00.760Z&lt;\/LastUpdateTime&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;\/Contact&gt;<br \/>\n\t&nbsp; &lt;\/content&gt;<br \/>\n\t&nbsp; &lt;source&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;id&gt;http:\/\/api.constantcontact.com:443\/ws\/customers\/<em><strong>username<\/strong><\/em>\/contacts&lt;\/id&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;title type=&quot;text&quot;&gt;Contacts for Customer: <em><strong>username<\/strong><\/em>&lt;\/title&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;link href=&quot;contacts&quot;&gt;&lt;\/link&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;link href=&quot;contacts&quot; rel=&quot;self&quot;&gt;&lt;\/link&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;author&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;name&gt;<em><strong>username<\/strong><\/em>&lt;\/name&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;\/author&gt;<br \/>\n\t&nbsp;&nbsp;&nbsp; &lt;updated&gt;2011-06-03T17:14:10.175Z&lt;\/updated&gt;<br \/>\n\t&nbsp; &lt;\/source&gt;<br \/>\n\t&lt;\/entry&gt;<br \/>\n\t<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is not a typical post, but I just had to share as it took me a good afternoon of trial error to figure out&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"amp_status":""},"categories":[77],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/239"}],"collection":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/comments?post=239"}],"version-history":[{"count":2,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/239\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/posts\/239\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/media?parent=239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/categories?post=239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sitekickr.com\/blog\/wp-json\/wp\/v2\/tags?post=239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}