summaryrefslogtreecommitdiff
path: root/actions/twitapifriendships.php
diff options
context:
space:
mode:
authorzach <zach@copley.name>2008-07-20 03:09:05 -0400
committerzach <zach@copley.name>2008-07-20 03:09:05 -0400
commit140689800b03ff704f6c70260c2b740ad41578c0 (patch)
tree7d9fe90e1ae731f9275910302ec6063df2486d62 /actions/twitapifriendships.php
parent00a6f3d01510e01a5dcc0999a50fba7bafbcd5e1 (diff)
Twitter-compatible API - Error handling that better matches Twitter's
darcs-hash:20080720070905-ca946-dda57dd92210461361fd58b7a3244bf24c01e801.gz
Diffstat (limited to 'actions/twitapifriendships.php')
-rw-r--r--actions/twitapifriendships.php23
1 files changed, 15 insertions, 8 deletions
diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php
index 0253cb8e5..90e890e35 100644
--- a/actions/twitapifriendships.php
+++ b/actions/twitapifriendships.php
@@ -31,7 +31,7 @@ class TwitapifriendshipsAction extends TwitterapiAction {
$other = $this->get_user($id);
if (!$other) {
- $this->client_error(_('No such user'));
+ $this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
exit();
return;
}
@@ -39,7 +39,7 @@ class TwitapifriendshipsAction extends TwitterapiAction {
$user = $apidata['user'];
if ($user->isSubscribed($other)) {
- $this->client_error(_('Already subscribed.'));
+ $this->client_error("Could not follow user: $other->nickname is already on your list.", 403, $apidata['content-type']);
exit();
return;
}
@@ -55,7 +55,7 @@ class TwitapifriendshipsAction extends TwitterapiAction {
$result = $sub->insert();
if (!$result) {
- $this->server_error(_('Could not subscribe'));
+ $this->client_error("Could not follow user: $other->nickname.", 400, $apidata['content-type']);
exit();
return;
}
@@ -101,7 +101,7 @@ class TwitapifriendshipsAction extends TwitterapiAction {
$sub->delete();
$sub->query('COMMIT');
} else {
- $this->client_error(_('Not subscribed'));
+ $this->client_error(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
exit();
}
@@ -127,14 +127,21 @@ class TwitapifriendshipsAction extends TwitterapiAction {
function exists($args, $apidata) {
parent::handle($args);
+
+
$user_a_id = $this->trimmed('user_a');
$user_b_id = $this->trimmed('user_b');
+
$user_a = $this->get_profile($user_a_id);
$user_b = $this->get_profile($user_b_id);
+ if($user_a) { print "got user a profile";}
+ if($user_b) { print "got user b profile";}
+
+
if (!$user_a || !$user_b) {
- $this->client_error(_('No such user'));
- return;
+ $this->client_error(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
+ exit();
}
if ($user_a->isSubscribed($user_b)) {
@@ -151,20 +158,20 @@ class TwitapifriendshipsAction extends TwitterapiAction {
break;
case 'json':
print json_encode($result);
- print "\n";
break;
default:
print $result;
break;
}
+ exit();
}
function get_profile($id) {
if (is_numeric($id)) {
return Profile::staticGet($id);
} else {
- $user = User::staticGet('nickname', $id);
+ $user = User::staticGet('nickname', $id);
if ($user) {
return $user->getProfile();
} else {