I'm using twitter API tweepy and I want to use api.list_timeline() function.
It says I must provide either a list ID or slug and owner.
How can I get these information?
The id of a twitter list can be found by looking at end end of the URL of the list on twitter web, for example in the url https://twitter.com/i/lists/1269293736644796416, 1269293736644796416 would be the id.
To implement it into your code you would simply write:
api.list_timeline(list_id=1269293736644796416)
Related
I have a list of "n" Twitter ID representing users I would like to download.
To retrieve their user profile info, should I use n times the api call get_user or there exist a method to pass the entire list and retrieve all the info within one single api call, within the twitter rate time limit?
I tried something like
api.search_users(A)
api.search_users(id in A)
where A contains the list of id
but it does not work.
Anyone helping?
You can use the Twitter API resource https://dev.twitter.com/rest/reference/get/users/lookup. It can return user objects for at most 100 users at a time.
You can use this in Tweepy like:
user_objects = api.lookup_users(user_ids=list_of_at_most_100_user_ids)
Much of this answer first appeared as part of https://stackoverflow.com/a/42946854/1921546
I'm trying to find a way to retrieve all videos posted by a given user (eg: https://www.youtube.com/user/laliga/videos).
All the examples I've found online or the doc (https://developers.google.com/youtube/v3/docs/) seems to require either a playlist ID, channel ID or video ID.
Is there any way I can directly query the author's videos or am I forced to retrieve all playlists and then iterate over?
Thanks
You just need to map the user name to its channelID first via the YouTube API like so:
https://www.googleapis.com/youtube/v3/channels?forUsername=USER_NAME&part=id&key=API_KEY
Full docs: https://developers.google.com/youtube/v3/docs/channels/list
Then you can make a Videos:List call with that channelID to get the videos.
1)take your google key id and channel id and put inside below url
https://www.googleapis.com/youtube/v3/search?key=APIKEY&channelId=CHANNELID&part=snippet,id&order=date&maxResults=20
ex
https://www.googleapis.com/youtube/v3/search?key=adsjsdakhkjshd&channelId=sdahghsadhgj&part=snippet,id&order=date&maxResults=20
Twitter has recently implemented an automatic way of quoting tweets. It basically extracts an url from a tweet and shows it embedded within your tweet.
My problem is: how do I 'retweet with a comment' without showing the original tweet URL via API?
Retweeting from the website makes the RT look like this .
But when I'm manually prepending a tweet url to my tweet, it looks like this .
notice the literal url.
your tweet has a quoted_status, just put the tweet url as attachment_url args, e.g.
client.update('cool', attachment_url: 'https://twitter.com/emorima/status/1061581991798169600')
it's ruby code with twitter gem
My understanding is that you are achieving the closest solution that Twitter API offers. This thread talks about doing the following:
do a status update, with the 'status' field containing the text of the original tweet, followed by the link to the original tweet. The 'in_reply_to_status_id' field should not be set. This action does not result in the "retweet count" being increased.
do a retweet, which will increase the retweet count.
Based on lfx_cool's answer, I was able to achieve it with this:
statuses/update
post('https://api.twitter.com/1.1/statuses/update.json', {
status:'Some comment', attachment_url:`https://twitter.com/${user.screen_name}/status/${id_str}`,
});
I've to call this Twitter API's method
https://api.twitter.com/1.1/lists/statuses.json?list_id=12345
to retrieve the tweets by the user in the list.
But my customer provide me only the name of the list and I've no idea how to get the list id using the list name.
The list is this: https://twitter.com/DatasportNews/lists/i-campioni-di-brasile2014.
I've tried with this method
https://api.twitter.com/1.1/lists.json?screen_name=i-campioni-di-brasile2014
to get the id list but always return this message
{"errors":[{"message":"Your credentials do not allow access to this resource","code":220}]}.
I'm logged with api key and api secret and get the token well, but this method doesn't work.
Ideas ?
The list name in the URL is referred to as the slug. When you want to request statuses from a list using a slug, you simply also need to pass the owner_screen_name.
For example, in your case:
/1.1/lists/statuses.json?slug=i-campioni-di-brasile2014&owner_screen_name=DatasportNews
More details on this are on the endpoint's doc page at https://dev.twitter.com/docs/api/1.1/get/lists/statuses
The goal here is to be able to "tweet" a link of the format
www.example.com/page.aspx#1, and get the number of "tweets" for that link... Basically, what the out-of-the-box Twitter button does for any normal link.
Reason for this is because the page displays different content based on the ID after the #, so there is a need to count which specific item was "tweeted" and how many times.
I tried passing that URL to the Twitter service to get the count (http://urls.api.twitter.com/1/urls/count.json?url=), but the JSON object I get back only has
{"count":0,"url":"www.example.com/page.aspx/"}.
The link for the Twitter button looks like this (done in JavaScript)
var twtLink = 'http://twitter.com/intent/tweet?url='+encodeURIComponent(twtUrl)+'&counturl='+encodeURIComponent(twtUrl);
Any suggestions would be appreciated.
Thanks!
Twitter actually re-interrupts all URL's with their own custom t.co wrapper. This is good news for your use case. You can use these unique t.co links with the counter API.
If you include the attribute &include_entities=1 to the end of some Twitter REST API calls you get back expanded info including the URL's in the tweets. You will see the original URL as well as the shortened URL version. Pass the shortened URL version into the counter API.