Does anyone know how can I get the replied tweets to a particular tweet via Tweepy? It's so confusing for me, because when I try to retrieve the replies with this code to get the replies to a particular tweet ("status_id"), the result is so strange.
api = tweepy.API(auth)
s = api.search(q=api.get_status("status_id").user.name, since_id="status_id")
for example for a tweet with status_id "950489574823940096", it returns 15 statuses, while it has only 6 replies.
Related
Hey whatup all you people. Question about the payload sent to a Twitter Account Activity API webhook. According to the documentation I could find, TweetObjects for the the following events are all included under the tweet_create_events:
Tweet status payload when any of the following actions are taken by or to the subscription user: Tweets, Retweets, Replies, #mentions, QuoteTweets, Retweet of Quote Tweets.
Looks like for #mentions there is an additional key user_has_blocked included, but besides that, is there any way to tell if the event was a Tweet vs. Retweet vs. a Reply, etc?
I assume there must be, but I can't find any documentation on it.
Thanks in advance!
Alright here's what I figured out from testing all the scenarios.
The twitter user who initiated the event can be found in
tweet.user
It's a Reply if :
tweet.in_reply_to_status_id_str != null
It's an #Mention if:
tweet.in_reply_to_user_id != null && tweet.in_reply_to_status_id_str == null
It's a Retweet if:
tweet.retweeted_status != null
It's a Quote if:
tweet.is_quote_status == true
Otherwise, it's a Tweet.
I have been integrated a twitter feed into my Rails 4 application using this gem.
Able to fetched twitter home timeline feeds using following twitter gem method
Method:
twitter.home_timeline
and this will return last 20 tweets of home_timeline
To fetch first page tweets, i have added following options to the method which will return first 200 tweets in page 1.
Method:
twitter.home_timeline(:page => 1, :count => 200)
Here, everytime i have to provide page number manually like :page => 2, :page => 3,..and so on to fetch next page tweets.
So, is their any method or way to get total page counts for twitter home time tweets using twitter gem?
As mentioned in the official documentation:
Note: This method can only return up to 800 Tweets, including
retweets.
Meaning that you will never be able to get tweets greater than page 4 (while using count as 200)
To answer the question in headline, gem simply makes a call and pass all provided parameters, including page and count, to twitter API - see source
def home_timeline(options = {})
perform_get_with_objects('/1.1/statuses/home_timeline.json', options, Twitter::Tweet)
end
So whatever logic you get is logic from the twitter API. For API, you can read official doc here. Paging is additionally explained here. As indicated in other answer, there is a limit for statuses/home_timeline call:
Up to 800 Tweets are obtainable on the home timeline. It is more
volatile for users that follow many users or follow users who tweet
frequently.
Meanwhile, you can test the API https://dev.twitter.com/rest/tools/console - was helpful link for me
I am trying to get the number of friends for a userid, I can see that this userid is a friend but how do I get there total number of friends?
I have tried using the /{user-id}/friends endpoint but I get a privilege error. Using /{user-id-a}/friends/{user-id-b} I just get my friend data.
You need to use /{user_id}/friends. Therefore you need to gather the user_friends permission during the login dialog of your app.
See
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/friends/
The response for the call will contain a field summary.total_count with the total number of friends this user_id has. Keep in mind that only the friends which are also using the same app will be returned in the friends data array. If you just want the total count, the info returned should be sufficient.
I am new to the Twitter API and I'm having an issue with the user_timeline API.
I am using the following REST query:
https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=twitterapi&count=50
which is provides the user's timeline data, however it only gives the user's tweets; I want all tweets by and about the user (i.e. the user's tweets, and mentions of the user by the user's followers).
Thanks in advance!
You can access this by searching for the user's # handle. This will return tweets which mention #user and also tweets by #user.
Twitter API - Search
--
I've no experience about formatting for JSON calls but the following should be enough:
https://api.twitter.com/1.1/search/tweets.json?q=%40ataulm
The %40 is for the # symbol, and ataulm is the user name you wish to query. See the page linked for default values to the other parameters - this will, for example, only return 15 tweets per "page" (not sure what a page refers to), but can be set to a maximum of 100 per page, using the count parameter.
"https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser.'&count=500'
BUt it is giving only 200 records.
I'm looking to be able to return a JSON list of posts from a set of Facebook users with the Koala gem either through FQL or the Graph API. Currently I'm using the batch function of Koala to make a call for the first 'x' number of items in from each user feed and then flattening the array and sorting by time. The issue with this is that I would like to be able to get the first 'x' number of items where it doesn't get 10 from each user but simply the 10 most recent posts from the users I queried so I can retrieve the next 10 from the feed akin to what you would expect from your own home feed.
This is what I currently have:
#oauth = Koala::Facebook::OAuth.new
#access_token = #oauth.get_app_access_token
#graph = Koala::Facebook::API.new(#access_token)
artists = []
followings.each do |following|
artists << following.artist
end
feed = #graph.batch do |batch_api|
artists.each do |artist|
feed | batch_api.get_connections(artist.facebook, "feed", {"limit" => "10"})
end
end
feed.flatten!
feed.sort! { |x, y| y["created_time"] <=> x["created_time"] }
EDIT
I believe I've found one possible solution with FQL as follows
batch_api.fql_query("SELECT post_id, source_id, likes, actor_id, message, type FROM stream WHERE source_id IN(artist1, artist2...)")
But I am now returned the error
[#<Koala::Facebook::APIError: OAuthException: (#606) Queries for multiple source_ids require a non-zero viewer that has granted read_stream permission>]
The issue with this is that my application does not require someone to login with Facebook and so I cannot request a read_stream permission. Is there anyway the Facebook app itself can request this?
It should work, but there is a FB bug described here:
I think that there is nothing to do on your part to solve it.