webservices

Image Collection and Resource

by Administrator on ‎03-25-2011 10:03 AM

The images collection represents all images for each folder that a user has in MyLibrary or MyLibrary Plus product.  The collection would return a list of all images in a given folder.

 

Request Format

 

 

GET https://api.constantcontact.com/ws/customers/{user-name}/library/folders/{folder-id}/images

Required Headers

        accept: application/atom+xml
   content-type: application/atom+xml

 

 

For more information about listing images, refer to Managing Images.

 

Response Format

 

Each <atom:entry> element represents an image.  An image's unique ID is given by <id>.  The details at the collection level include the image type, dimensions, size, public URL as well as the <id> and <link> for the folder to which each image belongs.

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<atom:feed xmlns:atom="http://www.w3.org/2005/Atom">
<atom:title>Images</atom:title>
<atom:updated>2010-07-15T17:59:15.208-04:00</atom:updated>
<atom:id>tag:api.constantcontact.com,2010:/ws/customers/joesflowers/library/folders/2/images</atom:id>
<atom:entry>
<atom:title>1278424356346.gif</atom:title>
<atom:link rel="edit" href="/ws/customers/joesflowers/library/folders/2/images/917"/>
<atom:updated>2010-07-06T09:51:38.649-04:00</atom:updated>
<atom:id>tag:api.constantcontact.com,2010:/ws/customers/joesflowers/library/folders/2/images/917</atom:id>
<atom:content>
<Image>
<FileName>1278424356346.gif</FileName>
<ImageURL>https://origin.ih.constantcontact.com/fs030/1100337304266/img/917.gif  </ImageURL>
<Height>422</Height>
<Width>439</Width>
<Folder id="tag:api.constantcontact.com,2010:/ws/customers/joesflowers/library/folders/2">
<Name>1278424351586</Name>
<Link>
<href>/ws/customers/joesflowers/library/folders/2</href>
</Link>
</Folder>
<MD5Hash>990ca0ed790e033668111c2b402b6b53</MD5Hash>
<FileSize>64712</FileSize>
<LastUpdated>2010-07-06T09:51:38.649-04:00</LastUpdated>
<Link>
<href>/ws/customers/joesflowers/library/folders/2/images/917</href>
</Link>
<FileType>GIF</FileType>
</Image>
</atom:content>
</atom:entry>
<atom:entry>
<atom:title>1278424356346.jpeg</atom:title>
<atom:link rel="edit" href="/ws/customers/joesflowers/library/folders/2/images/920"/>
<atom:updated>2010-07-06T09:51:41.156-04:00</atom:updated>
<atom:id>tag:api.constantcontact.com,2010:/ws/customers/joesflowers/library/folders/2/images/920</atom:id>
<atom:content>
<Image>
<FileName>1278424356346.jpeg</FileName>
<ImageURL>https://origin.ih.constantcontact.com/fs030/1100337304266/img/920.jpg  </ImageURL>
<Height>422</Height>
<Width>439</Width>
<Folder id="tag:api.constantcontact.com,2010:/ws/customers/joesflowers/library/folders/2">
<Name>1278424351586</Name>
<Link>
<href>/ws/customers/joesflowers/library/folders/2</href>
</Link>
</Folder>
<MD5Hash>ee988e4958b326b9151a062b4b17d57f</MD5Hash>
<FileSize>112315</FileSize>
<LastUpdated>2010-07-06T09:51:41.156-04:00</LastUpdated>
<Link>
<href>/ws/customers/joesflowers/library/folders/2/images/920</href>
</Link>
<FileType>JPG</FileType>
</Image>
</atom:content>
</atom:entry>
</atom:feed>

Request Format

 

POST https://api.constantcontact.com/ws/customers/{user-name}/library/folders/{folder-id}/images

 

To learn more about uploading an image, please refer to Managing Images as well as our Image Reference Guide.

 

The request must be a Multipart/Related request consisting of the XML that contains details of the image being uploaded and the binary stream of the image itself.

 

 

Required Header for Both Parts

    accept: application/atom+xml


Required Headers for XML Part

    content-type: application/atom+xml


Required Headers for Image Part

    content-type: image/jpg, image/jpeg, image/gif or image/png

    transfer-encoding: binary

 

The first part of the request must contain the XML body about the image itself.  Its content-type header must be set to application/atom+xml, and the XML body should look like the following:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
<atom:content>
<Image>
<FileName>1278008252289.gif</FileName>
<MD5Hash>990ca0ed790e033668111c2b402b6b53</MD5Hash>
<Description />
</Image>
</atom:content>
</atom:entry

The second part of the request must be the binary stream of the image itself.  The second part's content-type must be defined with the image type, such as image/jpg, image/gif or image/png.  You must set transfer-encoding for the second part to be binary so the image will be uploaded properly.

 

Image Resource

 

The image resource represents individual images that are stored in the user's account.  You need to use the image resource to get more details of a particular image.

 

Request Format

 

 

GET https://api.constantcontact.com/ws/customers/{user-name}/library/folders/{folder-id}/images/{image-i...

Required Headers

   accept: application/atom+xml
   content-type: application/atom+xml


 

For more information about obtaining details of an image, refer to Managing Images.

 

Response Format

 

For the GET request, you receive the following XML body:

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom">
<atom:title>Bengal Tiger.JPG</atom:title>
<atom:link rel="edit" href="/ws/customers/joesflowers/library/folders/1/images/1"/>
<atom:updated>2010-04-20T16:10:10.713-04:00</atom:updated>
<atom:id>tag:api.constantcontact.com,2010:/ws/customers/joesflowers/library/folders/1/images/1</atom:id>
<atom:content>
<Image>
<FileName>Bengal Tiger.JPG</FileName>
<ImageURL>https://origin.ih.constantcontact.com/fs081/1100325770403/img/1.jpg  </ImageURL>
<Height>257</Height>
<Width>226</Width>
<Description>tiger alt</Description>
<MD5Hash>401ba3a6f45834e0df0bba7d054c3c29</MD5Hash>
<FileSize>50362</FileSize>
<LastUpdated>2010-04-20T16:10:10.713-04:00</LastUpdated>
<ImageUsages>
<ImageUsage>
<Name>Attend Constant Contact Event</Name>
<Link>
<href>/ws/customers/joesflowers/campaigns/1100338276745</href>
<relationship>edit</relationship>
</Link>
</ImageUsage>
</ImageUsages>
<FileType>JPG</FileType>
</Image>
</atom:content>
</atom:entry>

 

 

URI Format


URI Component Description
user-name

The account owner's Constant Contact user name.
Value must be in lower case.

images

Represent a collection of images that in a particular folder.
image-id

Represents an individual image

It can be obtained from the Location header after creating a new image or from the last numeric ID in the <id> element.

 

Image Data XML Elements Specifications


Element Name Allowed Values Updatable? Required on POST Required on PUT Notes
FileName Less than 80 characters. All characters other than \\ / : * ? \ < > | Yes Yes Not Supported  
ImageURL NA No No Not Supported  
Height NA No No Not Supported  
Width NA No No Not Supported  
Description   Yes Yes Not Supported  
MD5Hash NA No Yes Not Supported Needs to match image data on POST
FileSize NA No No Not Supported  
LastUpdated NA No No Not Supported  
ImageUsages

<ImageUsage> element.
See below.

No No Not Supported  
FileType NA No No Not Supported Will return one of the following values: JPG, GIF or PNG

 

ImageUsage XML Element Specifications


Element Name Allowed Values Updatable? Required on POST? Required on PUT? Notes
Name NA No No No Name of the campaign that uses this image
Link NA No No No  
href NA No No No Represents the reference that you need to use to query the campaign that uses this image