What is the PornCovers API
The PornCovers 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 PornCovers 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 dick, your secret key is BJz2LYhjOB4grzD8fhrt49rviSW3yvKT and you are searching for "jenna jameson".
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 = 'dick';
- $secret_key = 'BJz2LYhjOB4grzD8fhrt49rviSW3yvKT';
- $search_phrase = 'jenna jameson';
- $query_hash = md5($secret_key.$search_phrase);
- // $query_hash = c6a8e04a0cf9c1582a77d4e3bde9a705$xml_request_url = 'http://www.porncovers.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>Jenna Jameson Is The Masseuse Custom DVD</name>
- <id>283</id>
- <category>Movies</category>
- <subcategory>Adult</subcategory>
- <image>http://www.porncovers.com/image_system/images/d/6/d60f459e490c0d0884322431f1a8d1d3.jpg</image>
- <covers>
- <cover>
- <type>Front</type>
- <width>3400</width>
- <height>2289</height>
- <filesize>1583423</filesize>
- <uploaded_at>2007-02-14 20:02:35</uploaded_at>
- <average_rating>4</average_rating>
- <url>http://www.porncovers.com/show/283/jenna_jameson_is_the_masseuse_custom_dvd/front</url>
- <thumbnail>http://www.porncovers.com/image_system/covers_th/d/6/d64ae1ec9463efa87c13caf4cfc15698.jpg</thumbnail>
- </cover>
- <cover>
- <type>CD</type>
- <width>1694</width>
- <height>1747</height>
- <filesize>1036556</filesize>
- <uploaded_at>2007-02-14 20:02:35</uploaded_at>
- <average_rating>5</average_rating>
- <url>http://www.porncovers.com/show/283/jenna_jameson_is_the_masseuse_custom_dvd/cd</url>
- <thumbnail>http://www.porncovers.com/image_system/covers_th/9/f/9f2252907a8e0c5430f72b7d30b48703.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 - by adding the category name to the end of the request url.
For example, a search for jenna jameson covers:
http://www.porncovers.com/api/search/dick/15ebb4f2/jenna+jamesonBecomes a search for Beatles movie covers:
http://www.porncovers.com/api/search/dick/15ebb4f2/jenna+jameson/moviesComplete working example
The following example connects to the site, retrieves all results for "jenna jameson" and displays them.
- <?php
- $user_name = 'dick';
- $secret_key = 'BJz2LYhjOB4grzD8fhrt49rviSW3yvKTs';
- $search_phrase = 'jenna jameson';
- $query_hash = md5($secret_key.$search_phrase);
- $xml_request_url = 'http://www.porncovers.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.







