3 // Implements the del.icio.us API request for a user's recent posts, optionally filtered by
4 // tag and/or number of posts (default 15, max 100, just like del.icio.us).
6 // Set default and max number of posts
10 // Force HTTP authentication first!
11 require_once 'httpauth.inc.php';
12 require_once '../header.inc.php';
14 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
15 $userservice =& ServiceFactory::getServiceInstance('UserService');
17 // Check to see if a tag was specified.
18 if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
19 $tag = trim($_REQUEST['tag']);
23 // Check to see if the number of items was specified.
24 if (isset($_REQUEST['count']) && (intval($_REQUEST['count']) != 0)) {
25 $count = intval($_REQUEST['count']);
26 if ($count > $countMax)
31 $count = $countDefault;
34 // Get the posts relevant to the passed-in variables.
35 $bookmarks =& $bookmarkservice->getBookmarks(0, $count, $userservice->getCurrentUserId(), $tag);
37 $currentuser = $userservice->getCurrentUser();
38 $currentusername = $currentuser[$userservice->getFieldName('username')];
40 // Set up the XML file and output all the tags.
41 header('Content-Type: text/xml');
42 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
43 echo '<posts tag="'. (is_null($tag) ? '' : filter($tag, 'xml')) .'" user="'. filter($currentusername, 'xml') ."\">\r\n";
45 foreach ($bookmarks['bookmarks'] as $row) {
46 if (is_null($row['bDescription']) || (trim($row['bDescription']) == ''))
49 $description = 'extended="'. filter($row['bDescription'], 'xml') .'" ';
52 if (count($row['tags']) > 0) {
53 foreach($row['tags'] as $tag)
54 $taglist .= convertTag($tag) .' ';
55 $taglist = substr($taglist, 0, -1);
57 $taglist = 'system:unfiled';
59 // The privacy setting in scuttle is to set bStatus to 2 in the database.
60 if(trim($row['bStatus']) == '2') {
66 echo "\t<post href=\"". filter($row['bAddress'], 'xml') .'" shared="' . $shared . '" description="'. filter($row['bTitle'], 'xml') .'" '. $description .'hash="'. $row['bHash'] .'" tag="'. filter($taglist, 'xml') .'" time="'. gmdate('Y-m-d\TH:i:s\Z', strtotime($row['bDatetime'])) ."\" />\r\n";