delicious returns a proper error message when deleting non-existant items, which we do now, too
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@770 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
22c9a01ee8
commit
70c39a8eea
3 changed files with 16 additions and 10 deletions
10
doc/developers/api
Normal file
10
doc/developers/api
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
SemanticScuttle API
|
||||||
|
===================
|
||||||
|
|
||||||
|
SemanticScuttle tries to implement the delicious API v1 as closely as sensible.
|
||||||
|
|
||||||
|
Where it makes sense and the delicious API just does things plainly wrong
|
||||||
|
(i.e. when returning a wrong status code on an error), we do it better.
|
||||||
|
|
||||||
|
- http://www.delicious.com/help/api
|
||||||
|
- http://support.delicious.com/forum/comments.php?DiscussionID=5286&page=1
|
|
@ -215,7 +215,7 @@ class Api_PostsDeleteTest extends TestBaseApi
|
||||||
$this->assertTag(
|
$this->assertTag(
|
||||||
array(
|
array(
|
||||||
'tag' => 'result',
|
'tag' => 'result',
|
||||||
'attributes' => array('code' => 'something went wrong')
|
'attributes' => array('code' => 'item not found')
|
||||||
),
|
),
|
||||||
$res->getBody(),
|
$res->getBody(),
|
||||||
'', false
|
'', false
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
* The delicious API is implemented here.
|
* The delicious API is implemented here.
|
||||||
*
|
*
|
||||||
* The delicious API behaves like that:
|
* The delicious API behaves like that:
|
||||||
* - returns "done" even if the bookmark doesn't exist
|
|
||||||
* - we do it correctly
|
|
||||||
* - does NOT allow the hash for the url parameter
|
* - does NOT allow the hash for the url parameter
|
||||||
* - doesn't set the Content-Type to text/xml
|
* - doesn't set the Content-Type to text/xml
|
||||||
* - we do it correctly, too
|
* - we do it correctly, too
|
||||||
|
@ -35,26 +33,24 @@ $uId = $userservice->getCurrentUserId();
|
||||||
if (!isset($_REQUEST['url'])
|
if (!isset($_REQUEST['url'])
|
||||||
|| $_REQUEST['url'] == ''
|
|| $_REQUEST['url'] == ''
|
||||||
) {
|
) {
|
||||||
$deleted = false;
|
$msg = 'something went wrong';
|
||||||
} else if (!$bs->bookmarkExists($_REQUEST['url'], $uId)) {
|
} else if (!$bs->bookmarkExists($_REQUEST['url'], $uId)) {
|
||||||
//the user does not have such a bookmark
|
//the user does not have such a bookmark
|
||||||
// Note that del.icio.us only errors out if no URL was passed in;
|
|
||||||
// there's no error on attempting to delete a bookmark you don't have.
|
|
||||||
// this sucks, and I don't care about being different but correct here.
|
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
$deleted = false;
|
$msg = 'item not found';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$bookmark = $bs->getBookmarkByAddress($_REQUEST['url'], false);
|
$bookmark = $bs->getBookmarkByAddress($_REQUEST['url'], false);
|
||||||
$bId = $bookmark['bId'];
|
$bId = $bookmark['bId'];
|
||||||
$deleted = $bs->deleteBookmark($bId);
|
$deleted = $bs->deleteBookmark($bId);
|
||||||
|
$msg = 'done';
|
||||||
if (!$deleted) {
|
if (!$deleted) {
|
||||||
//something really went wrong
|
//something really went wrong
|
||||||
header('HTTP/1.0 500 Internal Server Error');
|
header('HTTP/1.0 500 Internal Server Error');
|
||||||
|
$msg = 'something really went wrong';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the XML file and output the result.
|
// Set up the XML file and output the result.
|
||||||
echo '<?xml version="1.0" standalone="yes" ?' . ">\r\n";
|
echo '<?xml version="1.0" standalone="yes" ?' . ">\r\n";
|
||||||
echo '<result code="' . ($deleted ? 'done' : 'something went wrong') . '" />';
|
echo '<result code="' . $msg . '" />';
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue