Reputation: 4356
I am using Tweepy and Python to access the Twitter API.
I would like to know if the following problem is common or it's happening just for me.
I am storing some tweets. Retweeted ones are stored in this fortmat:
RT @User [text of the tweet]
I notice here that even a user retweeted the text using the "Retweet" button, the text is always stored in the same format (RT @User [text of the tweet]
) and of course when the Twitter API adds "RT @user
" the whole text can exceeds 140 character and as a result it is stored but not in its full length.
If the problem is not a common bug, for those who used Tweepy, does the bug comes from it or from Twitter API ?
Upvotes: 3
Views: 5551
Reputation: 8400
Retweets are special kinds of tweets with an additional node called "retweeted_status
".
The original, unaltered tweet text of the original tweet is in the text field of retweeted_status, not the top-most text field like traditional tweets.
Try following,
import tweepy
import urllib2
import json
consumer_key='#'
consumer_secret='#'
access_token_key='#'
access_token_secret='#'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token_key, access_token_secret)
api = tweepy.API(auth)
public_tweets = api.user_timeline(screen_name="@HandleHere",count=25,page=1,include_rts=True)
all_items=[]
[all_items.append(i) for i in public_tweets]
for i in all_items:
try:
if i.retweeted_status:
print i.retweeted_status.text
except:
pass
It will print full retweeted tweet.
Upvotes: 5
Reputation: 325
This is not a bug but a normal behavior. To quote the tweeter documentation for the truncated field:
Indicates whether the value of the text parameter was truncated, for example, as a result of a retweet exceeding the 140 character Tweet length. Truncated text will end in ellipsis, like this ...
[...]
Note that while native retweets may have their toplevel text property shortened, the original text will be available under the retweeted_status object and the truncated parameter will be set to the value of the original status (in most cases, false).
Upvotes: 1