Current version doesn't include retweets by default, and there's no documentation as to how to turn them on/off.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

There's an enable retweets option. Is that only in the latest dev maybe?

jesss’s picture

The retweets are missing from the block data, but are still counted in the total number of tweets. So, if you set your block to display the three latest tweets, but one of them is a retweet, the block will only display two tweets.

It looks like the $rts parameter isn't being passed to twitter_pull_render() within twitter_pull_block_view().

/**
 * Implementation of hook_block_view()
 */
function twitter_pull_block_view($delta = '') {
  $info = twitter_pull_block_data();
  $b_info = $info["$delta"];
  $content = twitter_pull_render($b_info->tweetkey, $b_info->title, $b_info->number_of_items, $b_info->theme_key, $b_info->lazy_load);
  return array("subject"=>"", "content"=>$content);
}

The comments say that the $rts parameter defaults to TRUE, but the default for twitter_pull_render() and twitter_pull_retrieve() is NULL, so I believe that's incorrect.

function twitter_pull_render($twitkey, $title = NULL, $num_items = NULL, $themekey = NULL, $lazy_load = FALSE, $rts = NULL, $exclude_replies = NULL) {
function twitter_pull_retrieve($twitkey, $num_items = NULL, $rts = NULL, $exclude_replies = NULL) {

I manually passed TRUE through twitter_pull_render() and then retweets displayed in my block.

/**
 * Implementation of hook_block_view()
 */
function twitter_pull_block_view($delta = '') {
  $info = twitter_pull_block_data();
  $b_info = $info["$delta"];
  $content = twitter_pull_render($b_info->tweetkey, $b_info->title, $b_info->number_of_items, $b_info->theme_key, $b_info->lazy_load, $rts = TRUE); // <--- my hack
  return array("subject"=>"", "content"=>$content);
}

The less hacky solution would be to:

  1. Either update the documentation so that it correctly states that $rts defaults to FALSE or update twitter_pull_render and twitter_pull_retrieve to set the default to TRUE.
  2. Update twitter_pull_block_view to accommodate a retweets parameter which is passed through to twitter_pull_render().
jeffschuler’s picture

Version: 7.x-2.0-alpha2 » 7.x-2.x-dev
Issue summary: View changes
Status: Active » Needs review
FileSize
2.52 KB

Here's a shot at fixing this. It:

  • Changes the default value of $rts to TRUE, like the function docs say,
  • Adds those function docs to twitter_pull_render() (to match twitter_pull_retrieve())
  • Adds rts and exclude_replies as configurable block data.

It's working for my the block that my custom module creates. I'm not sure if this is working for the default blocks or other methods that Twitter Pull allows.

My custom module now implements twitter_pull_blocks() like this:

<?php
function ohc_tweets_twitter_pull_blocks() {
  return array(
    0 => (object) array(
      'delta' => 'my_module',
      'tweetkey' => '@my_twitter_account',
      'title' => '<none>',
      'name'  => 'Connect on Twitter',
      'number_of_items' => 3,
      'theme_key' => 'twitter_pull_listing',
      'rts' => TRUE,
      'exclude_replies' => FALSE,
    )
  );
}
?>
jesss’s picture

I couldn't get the patch to apply with git (though that's probably my fault -- I'm a git novice), but I applied it manually and retweets are now showing as expected.

Retweets are still included in the count of the tweets returned, even if they're not included in the call, but that's the behavior of the API, not the module. Explaining that in the documentation might be nice.

https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline

The value of count is best thought of as a limit to the number of tweets to return because suspended or deleted content is removed after the count has been applied. We include retweets in the count, even if include_rts is not supplied.

jesss’s picture

Status: Needs review » Reviewed & tested by the community
joachim’s picture

+++ b/twitter_pull.module
@@ -98,8 +98,12 @@ function twitter_pull_preprocess(&$variables, $hook) {
-function twitter_pull_render($twitkey, $title = NULL, $num_items = NULL, $themekey = NULL, $lazy_load = FALSE, $rts = NULL, $exclude_replies = NULL) {
+function twitter_pull_render($twitkey, $title = NULL, $num_items = NULL, $themekey = NULL, $lazy_load = FALSE, $rts = TRUE, $exclude_replies = NULL) {

What's the reason for changing the defaults here?

jeffschuler’s picture

The function docs in twitter_pull_retrieve() state that the default value for $rts is TRUE. The patch makes this so for both twitter_pull_retrieve and twitter_pull_render.

Pepper’s picture

This seems to still be a problem in the Nov 5, 2015 - 7.x-2.0-alpha3. But the patch worked for that version as well.

szeidler’s picture

The patch is working well and should be comitted, as the current implementation makes the twitter_pull blocks really inflexible to configure.