Getting List Id from Add List Post.

Regular Participant

Getting List Id from Add List Post.

How do I get your list Id of a List I just added using the:


<entry xmlns="http://www.w3.org/2005/Atom">
<id>data:,</id>
<title />
<author />
<updated>2008-04-16</updated>
<content type="application/vnd.ctct+xml">
<ContactList xmlns="http://ws.constantcontact.com/ns/1.0/">
<OptInDefault>false</OptInDefault>
<Name>A New List</Name>
<SortOrder>99</SortOrder>
</ContactList>
</content>
</entry>


 


Do you have a sample of the .php code to do this?


 


Thanks

2 REPLIES 2
Regular Participant

I tried doing what was indicated in the following link:


http://developer.constantcontact.com/doc/contactLists#retrieve_list



Search for: "If the new list is created successfully"


When I changed your class CC_Utility and added the following:



    class CC_Utility {


...


var $curlResponseHeaders = array();


...


        protected function doServerCall($request, $parameter = '', $type = "GET")  {


$this->curlResponseHeaders = array();


...


curl_setopt($ch, CURLOPT_HEADERFUNCTION, array(&$this,'readHeader'));


...


           $emessage = curl_exec($ch);         

           if ($this->curl_debug) {   echo $error = curl_error($ch);   }

           curl_close($ch);

print_r( $this->curlResponseHeaders );

           

           return $emessage;


       }


function readHeader( $ch, $header )

{

    $this->curlResponseHeaders[] = $header;

}


   }


 


I get this:

  



Failed writing headerArray
(
=> HTTP/1.1 201 Created

)





My added code is against the left margin...





Any help/ideas would be appreciated.

Thanks

 




 


 


 

Employee

When creating a list, we will return a number of headers along with XML representing the details of your newly created list. In this returned XML you would want to access the <id> node contained in the <entry> element, as this will contain the ID of your newly created list. An example of the XML returned is:





<?xml version="1.0" encoding="UTF-8"?>

<entry xmlns="http://www.w3.org/2005/Atom">

  <id>http://api.constantcontact.com/ws/customers/{user-name}/lists/75</id>

  <title type="text"></title>

  <author></author>

  <updated>2010-08-10T13:39:10.565Z</updated>

  <content type="application/vnd.ctct+xml">

    <ContactList xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/{user-name}/lists/75">

      <OptInDefault>false</OptInDefault>  

      <Name>List Response Test</Name>    

      <SortOrder>2</SortOrder>

      <ShortName>List Response</ShortName>

      <DisplayOnSignup>No</DisplayOnSignup>

      <Members id="http://api.constantcontact.com/ws/customers/{user-name}/lists/75/members"></Members>

    </ContactList>

    </content>

  <link href="/ws/customers/{user-name}/lists/75" rel="edit"></link>

</entry>



I have bolded the section containing the list ID. I hope this helps answer your question. If not, I may need some more clarification. 





 

David J

Developer Portal

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

Visit Page