Recently while attempting to use Twitter::REST::Tweets#statuses (gem version 6.2.0) I noticed that tweets had no text returned when the tweet_mode: extended option is set.
To test this, I wrote a small script:
tweet_ids = ["922321981", "979854652618375168"]
client.statuses(tweet_ids).each_with_index do |tweet, i|
puts "#{i+1}) Text: #{tweet.text}, Full Text: #{tweet.full_text}"
end
This will output the following (note that the second tweet is truncated):
1) Text: no, Full Text: no
2) Text: Guess what everyone? WE HIT 1000!! Thank you so much to all of my subscribers who helped us get here! Freya and I a… https://t.co/gL2HpqOgKt, Full Text: Guess what everyone? WE HIT 1000!! Thank you so much to all of my subscribers who helped us get here! Freya and I a… https://t.co/gL2HpqOgKt
If the script is changed so that tweet_mode: extended is set, the #text and #full_text values stop working:
tweet_ids = ["922321981", "979854652618375168"]
client.statuses(tweet_ids, tweet_mode: 'extended').each_with_index do |tweet, i|
puts "#{i+1}) Text: #{tweet.text}, Full Text: #{tweet.full_text}"
end
1) Text: , Full Text:
2) Text: , Full Text:
I believe the problem is that when tweet_mode: extended is set, the call to GET statuses/lookup will return a full_text attribute instead of a text attribute. My fix checks for the presence of full_text instead of text on Twitter::Tweet creation, in order to avoid breaking the existing #full_text method.
If the patch is applied, the first, script above WITHOUT tweet_mode set returns the following truncated output, as before:
1) Text: no, Full Text: no
2) Text: Guess what everyone? WE HIT 1000!! Thank you so much to all of my subscribers who helped us get here! Freya and I a… https://t.co/gL2HpqOgKt, Full Text: Guess what everyone? WE HIT 1000!! Thank you so much to all of my subscribers who helped us get here! Freya and I a… https://t.co/gL2HpqOgKt
The second script, WITH tweet_mode: extended set, outputs the following:
1) Text: no, Full Text: no
2) Text: Guess what everyone? WE HIT 1000!! Thank you so much to all of my subscribers who helped us get here! Freya and I are so excited about what we have planned for the future and we are sure y'all are going to love it! Stay tuned this Tuesday for more info on the surprises! https://t.co/vwRhXyLSy6, Full Text: Guess what everyone? WE HIT 1000!! Thank you so much to all of my subscribers who helped us get here! Freya and I are so excited about what we have planned for the future and we are sure y'all are going to love it! Stay tuned this Tuesday for more info on the surprises! https://t.co/vwRhXyLSy6
This means that Twitter::Tweet will continue to work as before while also functioning properly for extended mode. I welcome any comments or feedback on the pull request!
Recently while attempting to use
Twitter::REST::Tweets#statuses
(gem version 6.2.0) I noticed that tweets had no text returned when thetweet_mode: extended
option is set.To test this, I wrote a small script:
This will output the following (note that the second tweet is truncated):
If the script is changed so that
tweet_mode: extended
is set, the#text
and#full_text
values stop working:I believe the problem is that when
tweet_mode: extended
is set, the call to GET statuses/lookup will return afull_text
attribute instead of atext
attribute. My fix checks for the presence offull_text
instead oftext
onTwitter::Tweet
creation, in order to avoid breaking the existing#full_text
method.If the patch is applied, the first, script above WITHOUT
tweet_mode
set returns the following truncated output, as before:The second script, WITH
tweet_mode: extended
set, outputs the following:This means that
Twitter::Tweet
will continue to work as before while also functioning properly for extended mode. I welcome any comments or feedback on the pull request!