diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/api/posts_add.php | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/www/api/posts_add.php b/www/api/posts_add.php index b392a80..8b63a16 100644 --- a/www/api/posts_add.php +++ b/www/api/posts_add.php @@ -73,17 +73,25 @@ if (isset($_REQUEST['shared']) && (trim($_REQUEST['shared']) == 'no')) { } // Error out if there's no address or description -if (is_null($url) || is_null($description)) { - $added = false; +if (is_null($url)) { + header('HTTP/1.0 400 Bad Request'); + $msg = 'URL missing'; +} else if (is_null($description)) { + header('HTTP/1.0 400 Bad Request'); + $msg = 'Description missing'; } else { -// We're good with info; now insert it! - if ($bookmarkservice->bookmarkExists($url, $userservice->getCurrentUserId())) - $added = false; - else - $added = $bookmarkservice->addBookmark($url, $description, $extended, '', $status, $tags, null, $dt, true); + // We're good with info; now insert it! + if ($bookmarkservice->bookmarkExists($url, $userservice->getCurrentUserId())) { + $msg = 'something went wrong'; + } else { + $added = $bookmarkservice->addBookmark( + $url, $description, $extended, '', $status, $tags, null, $dt, true + ); + $msg = 'done'; + } } // Set up the XML file and output the result. -echo '<?xml version="1.0" standalone="yes" ?'.">\r\n"; -echo '<result code="'. ($added ? 'done' : 'something went wrong') .'" />'; +echo '<?xml version="1.0" standalone="yes" ?' . ">\r\n"; +echo '<result code="' . $msg .'" />'; ?>
\ No newline at end of file |