summaryrefslogtreecommitdiff
path: root/www/api/posts_add.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-09-29 20:55:14 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-09-29 20:55:14 +0000
commit3ff661c0e0180b7808b1b95f9d25cc736d710026 (patch)
treef8ef9fd5a0122941f6bc5bcf6ddc6ccf82a46bc6 /www/api/posts_add.php
parentda272b5a20bec8d39c6d9cdf2fd5573de99083be (diff)
downloadsemanticscuttle-3ff661c0e0180b7808b1b95f9d25cc736d710026.tar.gz
semanticscuttle-3ff661c0e0180b7808b1b95f9d25cc736d710026.tar.bz2
send 400 status code if a parameter is missing
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@775 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'www/api/posts_add.php')
-rw-r--r--www/api/posts_add.php26
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