Patrick's Aviation API
Table of Contents
• Overview• Get a Specific Video
• Get Videos By Tags
• Get Videos By User
• PHP XML Parser
Overview
The Patrick's Aviation application programming interface (API) allows developers to retrieve data on Patrick's Aviation videos, which you can do whatever you want with. Data is retrieved using REST requests and returned via XML.Get a Specific Video
You can retrieve data on a specific video by sending REST requests to the following URL. Replace the value of ID with the ID of the video you wish to retrieve (the ID can be found in the videos URL, ex: http://www.patricksaviation.com/videos/erwan_67/238/).Example Response
Get Videos By Tags
You can retrieve a list of videos and their corresponding data for a tag or keyword phrase by sending REST requests to the following URL. Replace the value of TAG with the tag or keyword phrase you wish to retrieve data for. Will return any number of videos in descending order of relevancy.By default, this returns videos that match all words specified by TAG. You can request videos that match an exact phrase by surrounding that phrase in double quotes (").
Example Response
Get Videos By User
You can retrieve a list of videos and their corresponding data uploaded by a specific user by sending REST requests to the following URL. Replace the value of USER_NAME with the user name of the user you'd like to retrieve data for (this must be encoded according to RFC 1738). Will return any number of videos in ascending order of their upload date.Example Response
PHP XML Parser
Here is an example XML parser written in PHP which can be used to retrieve and extract data.
<?php
$content = getXML("http://www.patricksaviation.com/api/?id=ID");
foreach($content['items'] as $item){
/* Example: Print the video(s) name. */ print $item['name']."<br />\n";
}
function getXML($file){
$itemtags = array('id', 'user', 'name', 'description', 'length', 'size', 'resolution', 'rating', 'views', 'comments', 'url', 'img', 'imgThumb', 'imgTiny');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_USERAGENT, "Please Enter Your Site Name Here");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$contents = curl_exec ($ch);
curl_close ($ch);
preg_match_all('/<video>(.*?)<\/video>/si', $contents, $items);
$items = $items[1];
$result['items'] = array();
$i = 0;
foreach($items as $item) {
foreach($itemtags as $itemtag){
preg_match("'<$itemtag.*?>(.*?)</$itemtag>'si", $item, $temp);
if($temp) $result['items'][$i][$itemtag] = trim($temp[1]);
}
$i++;
}
return $result;
}
?>


