/**
* Push content to the recipient.
*
* @param Horde_Push $content The content element.
* @param array $options Additional options.
*
* @return string The result description.
*/
public function push(Horde_Push $content, $options = array())
{
$tweet = $content->getSummary();
if ($content->hasReferences() && strlen($tweet) < 116 && class_exists('Horde_Service_UrlShortener_Base') && $this->_client !== null) {
$shortener = new Horde_Service_UrlShortener_TinyUrl($this->_client);
foreach ($content->getReferences() as $reference) {
$tweet .= ' ' . $shortener->shorten($reference);
if (strlen($tweet) > 115) {
break;
}
}
}
if ($content->hasTags()) {
foreach ($content->getTags() as $tag) {
if (strlen($tweet) + strlen($tag) < 139) {
$tweet .= ' #' . $tag;
}
}
}
if (empty($options['pretend'])) {
$this->_twitter->statuses->update($tweet);
return 'Pushed tweet to twitter.';
} else {
return sprintf('Would push tweet "%s" to twitter.', $tweet);
}
}