From 93ac0bcae3a600733045ad7a5bafabcdfd49d9e5 Mon Sep 17 00:00:00 2001 From: zach Date: Sun, 20 Jul 2008 04:34:28 -0400 Subject: Twitter-compatible API - refactoring and bug fixes darcs-hash:20080720083428-ca946-c14a92345366f2105b3c452a3899714d89692daa.gz --- actions/twitapifriendships.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'actions/twitapifriendships.php') diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index 90e890e35..19617a071 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -33,7 +33,6 @@ class TwitapifriendshipsAction extends TwitterapiAction { if (!$other) { $this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']); exit(); - return; } $user = $apidata['user']; @@ -41,7 +40,6 @@ class TwitapifriendshipsAction extends TwitterapiAction { if ($user->isSubscribed($other)) { $this->client_error("Could not follow user: $other->nickname is already on your list.", 403, $apidata['content-type']); exit(); - return; } $sub = new Subscription(); @@ -57,7 +55,6 @@ class TwitapifriendshipsAction extends TwitterapiAction { if (!$result) { $this->client_error("Could not follow user: $other->nickname.", 400, $apidata['content-type']); exit(); - return; } $sub->query('COMMIT'); @@ -66,7 +63,7 @@ class TwitapifriendshipsAction extends TwitterapiAction { $type = $apidata['content-type']; $this->init_document($type); - $this->show_profile($other); + $this->show_profile($other, $type); $this->end_document($type); exit(); } @@ -106,8 +103,8 @@ class TwitapifriendshipsAction extends TwitterapiAction { } $type = $apidata['content-type']; - $this->init_document($type); - $this->show_profile($other); + $this->init_document($type); + $this->show_profile($other, $type); $this->end_document($type); exit(); } @@ -135,10 +132,6 @@ class TwitapifriendshipsAction extends TwitterapiAction { $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(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']); exit(); @@ -152,15 +145,17 @@ class TwitapifriendshipsAction extends TwitterapiAction { switch ($apidata['content-type']) { case 'xml': - common_start_xml(); + $this->init_document('xml'); common_element('friends', NULL, $result); - common_end_xml(); + $this->end_document('xml'); break; case 'json': + $this->init_document('json'); print json_encode($result); + $this->end_document('json'); break; default: - print $result; + print $result; // Really? --Zach break; } -- cgit v1.2.3-54-g00ecf