protected $_request;
/**
+ * Hold the http client.
+ *
+ * @var Horde_Http_Client
+ */
+ protected $_httpClient;
+
+ /**
* Const'r
*
* @param array $config Configuration parameters:
}
/**
+ * Set the http client.
+ *
+ * @param Horde_Http_Client $client The http client
+ */
+ public function setHttpClient(Horde_Http_Client $client)
+ {
+ $this->_httpClient = $client;
+ }
+
+ /**
+ * Get the http client.
+ *
+ * @return Horde_Http_Client
+ */
+ public function getHttpClient()
+ {
+ return $this->_httpClient;
+ }
+
+ /**
* Lazy load the twitter classes.
*
* @param string $value The lowercase representation of the subclass.
if (!empty($cache) && $results = $cache->get($key, $this->_twitter->cacheLifetime)) {
return $results;
}
- $client = new Horde_Http_Client();
try {
- $response = $client->get($url, array('Authorization' => $this->_twitter->auth->buildAuthorizationHeader()));
+ $response = $this->_twitter->getHttpClient()->get($url, array('Authorization' => $this->_twitter->auth->buildAuthorizationHeader()));
} catch (Horde_Http_Exception $e) {
throw new Horde_Service_Twitter_Exception($e);
}
{
$client = new Horde_Http_Client();
try {
- $response = $client->post($url, $params, array('Authorization' => $this->_twitter->auth->buildAuthorizationHeader()));
+ $response = $this->_twitter->getHttpClient()->post($url, $params, array('Authorization' => $this->_twitter->auth->buildAuthorizationHeader()));
} catch (Horde_Http_Exception $e) {
throw new Horde_Service_Twitter_Exception($e);
}
$request->sign($this->_twitter->auth->oauth->signatureMethod,
$this->_twitter->auth->oauth,
$this->_twitter->auth->getAccessToken());
- $client = new Horde_Http_Client();
$url = ($url instanceof Horde_Url) ? $url : new Horde_Url($url);
$url->add($params);
try {
- $response = $client->get($url, array('Authorization' => $request->buildAuthorizationHeader('Twitter API')));
+ $response = $this->_twitter->getHttpClient()->get($url, array('Authorization' => $request->buildAuthorizationHeader('Twitter API')));
} catch (Horde_Http_Exception $e) {
throw new Horde_Service_Twitter_Exception($e);
}
$request->sign($this->_twitter->auth->oauth->signatureMethod,
$this->_twitter->auth->oauth,
$this->_twitter->auth->getAccessToken());
-
- $client = new Horde_Http_Client();
try {
- $response = $client->post($url, $params, array('Authorization' => $request->buildAuthorizationHeader('Twitter API')));
+ $response = $this->_twitter->getHttpClient()->post($url, $params, array('Authorization' => $request->buildAuthorizationHeader('Twitter API')));
} catch (Horde_Http_Exception $e) {
throw new Horde_Service_Twitter_Exception($e);
}
/* Fetch the stream data */
try {
- $stream = Horde_Serialize::unserialize($twitter->statuses->homeTimeline(), Horde_Serialize::JSON);
+ $stream = Horde_Serialize::unserialize($twitter->statuses->homeTimeline(array('include_entities' => 'true')), Horde_Serialize::JSON);
} catch (Horde_Service_Twitter_Exception $e) {
$msg = Horde_Serialize::unserialize($e->getMessage(), Horde_Serialize::JSON);
return $msg
$html .= ' <div class="fbstreambody">';
$html .= $body;
$html .= '<div class="fbstreaminfo">' . sprintf(_("Posted %s via %s"), Horde_Date_Utils::relativeDateTime(strtotime($tweet->created_at), $GLOBALS['prefs']->getValue('date_format')), $appText) . '</div>';
+// if (!empty($tweet->retweeted_status)) {
+// $html .= '<div class="fbstreaminfo">' . sprintf(_("Retweeted by %s"), $tweet->user->screen_name) . '</div>';
+// }
$html .= '<div class="fbstreaminfo">' . Horde::link('#', '', '', '', 'Horde.twitter.buildReply(\'' . $tweet->id . '\', \'' . $tweet->user->screen_name . '\', \'' . $tweet->user->name . '\')') . _("Reply") . '</a>';
$html .= ' | ' . Horde::link('#', '', '', '', 'Horde.twitter.retweet(\'' . $tweet->id . '\')') . _("Retweet") . '</a>';
$html .= '</div><div class="clear"> </div></div>';
$oauth = new Horde_Oauth_Consumer($params);
/* Create the Twitter client */
+ // @TODO: use a binder - especially once we start integrating other
+ // apps with Twitter
$twitter = new Horde_Service_Twitter(array('oauth' => $oauth,
'cache' => $cache));
+ $twitter->setHttpClient($GLOBALS['injector']->getInstance('Horde_Http_Client'));
$auth_token = new Horde_Oauth_Token($token['key'], $token['secret']);
$twitter->auth->setToken($auth_token);