From 888b5f03f8a149ad3c2ce3c8987dbb11b5dd4d72 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Wed, 30 Jun 2010 18:05:28 -0400 Subject: [PATCH] Implement Retweet function in twitter client --- horde/lib/Block/twitter_timeline.php | 21 ++++++++++++++++++++- horde/services/twitter.php | 6 ++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/horde/lib/Block/twitter_timeline.php b/horde/lib/Block/twitter_timeline.php index 3895459cb..306dbd271 100644 --- a/horde/lib/Block/twitter_timeline.php +++ b/horde/lib/Block/twitter_timeline.php @@ -175,6 +175,7 @@ class Horde_Block_Horde_twitter_timeline extends Horde_Block $html .= $body; $html .= '
' . sprintf(_("Posted %s via %s"), Horde_Date_Utils::relativeDateTime(strtotime($tweet->created_at), $GLOBALS['prefs']->getValue('date_format')), $appText) . '
'; $html .= '
' . Horde::link('#', '', '', '', 'Horde.twitter.buildReply(\'' . $tweet->id . '\', \'' . $tweet->user->screen_name . '\', \'' . $tweet->user->name . '\')') . _("Reply") . ''; + $html .= ' | ' . Horde::link('#', '', '', '', 'Horde.twitter.retweet(\'' . $tweet->id . '\')') . _("Retweet") . ''; $html .= '
 
'; } $html .= ''; @@ -198,7 +199,25 @@ class Horde_Block_Horde_twitter_timeline extends Horde_Block params = new Object(); params.actionID = 'updateStatus'; params.statusText = statusText; - params.inReplyTo = this.inReplyTo; + params.params = { 'in_reply_to_status_id': this.inReplyTo }; + new Ajax.Request('$endpoint', { + method: 'post', + parameters: params, + onComplete: function(response) { + this.updateCallback(response.responseJSON); + }.bind(this), + onFailure: function() { + {$spinner}.toggle(); + this.inReplyTo = ''; + } + }); + }, + + retweet: function(id) { + params = { + actionID: 'retweet', + tweetId: id + }; new Ajax.Request('$endpoint', { method: 'post', parameters: params, diff --git a/horde/services/twitter.php b/horde/services/twitter.php index f505353a3..fb886aa9e 100644 --- a/horde/services/twitter.php +++ b/horde/services/twitter.php @@ -74,6 +74,12 @@ case 'updateStatus': header('Content-Type: application/json'); echo $result; exit; + +case 'retweet': + $result = $twitter->statuses->retweet(Horde_Util::getPost('tweetId')); + header('Content-Type: application/json'); + echo $result; + exit; } /* No requested action, check to see if we have a valid token */ -- 2.11.0