What is the AllCDCovers API
The AllCDCovers API has been created to allow our partners to easily add content to their site, by integrating our content into their design.
The API allows full-freedom in how you use the content you retrieve, and is a great way to add that extra something to your site.
To use the API you must apply for an API Developer user name and key. When applying please provide as many details possible about your intended use of the API.
Thank you for trying out the AllCDCovers API.
How to use the API
The API accepts REST requests and returns results as a simple XML file.
To receive an XML file with search results, send a request to a url formatted like this:
Let's say, for example, that your username is lennon_22, your secret key is BJz2LYhjOB4grzD8fhrt49rviSW3yvKT and you are searching for "beatles love".
The query_hash for this search is the md5 hash of your user name and the search phrase.
Note that all sample code in this page is written in PHP and uses the SimpleXML functions.
Here is an example of constructing a url for a cover search:
- <?php
- $user_name = 'lennon_22';
- $secret_key = 'BJz2LYhjOB4grzD8fhrt49rviSW3yvKT';
- $search_phrase = 'beatles love';
- $query_hash = md5($secret_key.$search_phrase);
- // $query_hash = 15ebb4f2c2664512db7a2f7f955f2172$xml_request_url = 'http://www.allcdcovers.com/api/search/'.$user_name.'/'.$query_hash.'/'.urlencode($search_phrase);?>
To retrieve the xml results file, simply send a query to the url we constructed in the previous step:
- $xml = new SimpleXMLElement($xml_request_url, null, true);
The results you will receive in XML will take this form:
- <rsp stat="ok" version="1.0">
- <title>
- <name>Beatles - Love (2006) Retail CD</name>
- <id>3526</id>
- <category>Music</category>
- <subcategory>Albums</subcategory>
- <image>http://www.allcdcovers.com/image_system/images/f/e/fe4872d55f2466abac060bbef03b47df.jpg</image>
- <covers>
- <cover>
- <type>Front</type>
- <width>1438</width>
- <height>1405</height>
- <filesize>388343</filesize>
- <uploaded_at>2007-02-14 20:02:35</uploaded_at>
- <average_rating>4</average_rating>
- <url>http://www.allcdcovers.com/show/3526/beatles_love_2006_retail_cd/front</url>
- <thumbnail>http://www.allcdcovers.com/image_system/covers_th/5/2/5203d85ecdb700645a1232c850139ffa.jpg</thumbnail>
- </cover>
- <cover>
- <type>Back</type>
- <width>1773</width>
- <height>1379</height>
- <filesize>436556</filesize>
- <uploaded_at>2007-02-14 20:02:35</uploaded_at>
- <average_rating>5</average_rating>
- <url>http://www.allcdcovers.com/show/3526/beatles_love_2006_retail_cd/back</url>
- <thumbnail>http://www.allcdcovers.com/image_system/covers_th/c/1/c1d27a022bf1b44349daf5660d969d38.jpg</thumbnail>
- </cover>
- </covers>
- </title>
- </rsp>
Now all you have to do is go over the results file and format your output.
- foreach ($xml as $title) {
- echo 'Title: '.$title->name;
- echo 'Category: '.$title->category.': '.$title->subcategory;
- echo 'Image: '.$title->image;
- foreach ($title->covers->cover as $cover) {
- echo 'Cover type:'.$cover->type;
- echo 'Resolution:'.$cover->width.' '.$cover->height;
- echo 'Filesize:'.$cover->filesize;
- echo 'Upload date:'.$cover->uploaded_at;
- echo 'Average rating:'.$cover->average_rating;
- echo 'Download page:'.$cover->url;
- echo 'Thumbnail:'.$cover->thumbnail;
- }
- }
- ?>
Limiting results by category
You can limit the results returned to just one category of titles - such as music, movies or games - by adding the category name to the end of the request url.
For example, a search for Beatles covers:
http://www.allcdcovers.com/api/search/lennon_22/15ebb4f2/beatlesBecomes a search for Beatles movie covers:
http://www.allcdcovers.com/api/search/lennon_22/15ebb4f2/beatles/moviesComplete working example
The following example connects to the site, retrieves all results for "beatles love" and displays them.
- <?php
- $user_name = 'lennon_22';
- $secret_key = 'BJz2LYhjOB4grzD8fhrt49rviSW3yvKTs';
- $search_phrase = 'beatles love';
- $query_hash = md5($secret_key.$search_phrase);
- $xml_request_url = 'http://www.allcdcovers.com/api/search/'.$user_name.'/'.$query_hash.'/'.urlencode($search_phrase);
- $xml = new SimpleXMLElement($xml_request_url, null, true);
- if (isset($xml->err)) {
- echo $xml->err['msg'];
- } else {
- foreach ($xml as $title) {
- echo 'Title: '.$title->name;
- echo 'Category: '.$title->category.': '.$title->subcategory;
- echo 'Image: '.$title->image;
- echo 'Image: '.$title->image;
- foreach ($title->covers->cover as $cover) {
- echo 'Cover type:'.$cover->type;
- echo 'Resolution:'.$cover->width.' '.$cover->height;
- echo 'Filesize:'.$cover->filesize;
- echo 'Upload date:'.$cover->uploaded_at;
- echo 'Average rating:'.$cover->average_rating;
- echo 'Download page:'.$cover->url;
- echo 'Thumbnail:'.$cover->thumbnail;
- }
- }
- }
- ?>
And that's it… Simple as that.









