]> projects.mako.cc - scuttle/blob - api/posts_delete.php
Tagged 0.7.5
[scuttle] / api / posts_delete.php
1 <?php
2 // Implements the del.icio.us API request to delete a post.
3
4 // del.icio.us behavior:
5 // - returns "done" even if the bookmark doesn't exist;
6 // - does NOT allow the hash for the url parameter;
7 // - doesn't set the Content-Type to text/xml (we do).
8
9 // Force HTTP authentication first!
10 require_once('httpauth.inc.php');
11 require_once('../header.inc.php');
12
13 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
14 $userservice =& ServiceFactory::getServiceInstance('UserService');
15
16 // Note that del.icio.us only errors out if no URL was passed in; there's no error on attempting
17 // to delete a bookmark you don't have.
18
19 // Error out if there's no address
20 if (is_null($_REQUEST['url'])) {
21     $deleted = false;
22 } else {
23     $bookmark = $bookmarkservice->getBookmarkByAddress($_REQUEST['url']);
24     $bid = $bookmark['bId'];
25     $delete = $bookmarkservice->deleteBookmark($bid);
26     $deleted = true;
27 }
28
29 // Set up the XML file and output the result.
30 header('Content-Type: text/xml');
31 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
32 echo '<result code="'. ($deleted ? 'done' : 'something went wrong') .'" />';
33 ?>

Benjamin Mako Hill || Want to submit a patch?