2 // Implements the del.icio.us API request to add a new post.
4 // del.icio.us behavior:
5 // - tags can't have spaces
6 // - address and description are mandatory
9 // - Additional 'status' variable for privacy
10 // - No support for 'replace' variable
12 // Force HTTP authentication
13 require_once 'httpauth.inc.php';
14 require_once '../header.inc.php';
16 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
17 $userservice =& ServiceFactory::getServiceInstance('UserService');
19 // Get all the bookmark's passed-in information
20 if (isset($_REQUEST['url']) && (trim($_REQUEST['url']) != ''))
21 $url = trim(urldecode($_REQUEST['url']));
25 if (isset($_REQUEST['description']) && (trim($_REQUEST['description']) != ''))
26 $description = trim($_REQUEST['description']);
30 if (isset($_REQUEST['extended']) && (trim($_REQUEST['extended']) != ""))
31 $extended = trim($_REQUEST['extended']);
35 if (isset($_REQUEST['tags']) && (trim($_REQUEST['tags']) != '') && (trim($_REQUEST['tags']) != ','))
36 $tags = trim($_REQUEST['tags']);
40 if (isset($_REQUEST['dt']) && (trim($_REQUEST['dt']) != ''))
41 $dt = trim($_REQUEST['dt']);
46 if (isset($_REQUEST['status'])) {
47 $status_str = trim($_REQUEST['status']);
48 if (is_numeric($status_str)) {
49 $status = intval($status_str);
50 if($status < 0 || $status > 2) {
54 switch ($status_str) {
68 // Error out if there's no address or description
69 if (is_null($url) || is_null($description)) {
72 // We're good with info; now insert it!
73 if ($bookmarkservice->bookmarkExists($url, $userservice->getCurrentUserId()))
76 $added = $bookmarkservice->addBookmark($url, $description, $extended, $status, $tags, $dt, TRUE);
79 // Set up the XML file and output the result.
80 header('Content-Type: text/xml');
81 echo '<?xml version="1.0" standalone="yes" ?'.">\r\n";
82 echo '<result code="'. ($added ? 'done' : 'something went wrong') .'" />';