From 3ff661c0e0180b7808b1b95f9d25cc736d710026 Mon Sep 17 00:00:00 2001
From: cweiske
Date: Wed, 29 Sep 2010 20:55:14 +0000
Subject: 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
---
www/api/posts_add.php | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
(limited to 'www')
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 '\r\n";
-echo '';
+echo '\r\n";
+echo '';
?>
\ No newline at end of file
--
cgit v1.2.3-54-g00ecf