Does a twitter account ID can be equals to a tweet ID? - twitter

Or do I have to build myself a unique identifier ?
(I use twitter4j API to retrieve tweets from my friends)

Yes they can. However the ID of a tweet is very often far more greater than a user ID (big long number vs. an ìnt < 1,000,000,000). They might be equals for very old tweets but definitely not for recent ones (for example Twitter hasn't got 271,674,757,445,996,545 users to make a confusion yet).

Related

is there an API to get all of an Instagram business account's posts that include a particular hashtag?

I am trying to get media with an hashtag that is specific to a particular user. Instead, the api seems to provide all the public images with the hashtags that is not specific to the account.
This is the api to get media nodes using hashtag that I tried:
{hashtag-id}/recent_media?user_id={iguserId}&fields=id,media_type,comments_count,like_count,caption
This one returns the public images associated with that particular hashtag in addition to the account's media that I need. For example:
I am requesting for images in a user's account that has #xxxx as hashtag. I am expecting the account's images alone containing xxxx tag. However, in the response I am receiving images from other accounts as well which has the same #xxxx hashtag. This api seems to work globally and I don't understand the use of 'user_id' parameter in the api.
Check out this API. Very simple to use and you can get media from a hashtag and specify an account. This will help you get all of an Instagram business account's posts.
Python 3.x Implementation:
import instaloader
# Get instance
L = instaloader.Instaloader()
#Load the UserName
profile = instaloader.Profile.from_username(L.context, USERNAME)
#Read the profile posts and downloads those containing the hashtags
for i in profile.get_posts():
if HASHTAG in i.caption_hashtags:
L.download_post(i, target=DIRECTORY_NAME)

Twitter API - last activity date of a user?

Is there any way to find out when was the last time a user was active, that is, either the last login date or tweet or retweet on Twitter via API? Any activity of a user.
This answer assumes you're watching a known list of Twitter users.
Pretty sure that you are not going to see the login date/time. If you request the user's tweets from the user's timeline, then those tweets are sorted by date/time (GET on https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi&include_rts=true). You might need to set include_rts to true in order to get back retweets. The time of the latest tweet gives you the time of the last activity.
Additionally you can add trim_user=true to keep the payload smaller.
Notice that those requests do count into the rate limit count. You can do bulk requests by using the users/lookup request, which lets you query up to 100 users with one request, which is more rate-limit-friendly.
Reference: https://dev.twitter.com/rest/reference/get/statuses/user_timeline

Twitter Phirehose - Getting a user stream of user other than the logged in user

$sc = new FilterTrackConsumer(OAUTH_TOKEN, OAUTH_SECRET, Phirehose::METHOD_FILTER);
$sc->setTrack(getTrackKeywords());
$sc->consume();
returns tweets that contain certain keywords, from any users.
$sc = new MyUserConsumer(OAUTH_TOKEN, OAUTH_SECRET);
$sc->consume();
returns tweets by the authorized (logged-in) user.
How do I get a stream that returns tweets tweeted by a specific user-- a user other than the one logged in / oauthed?
I think I found it.
$sc->setFollow(array(
1234, 5678, 901234573 //The user IDs of the twitter accounts to follow. All of
//these users must have given your app permission.
));
If you just want the public tweets of a set of users, take a look at the example/filter-track.php code that comes with Phirehose, but use setFollow() instead of setTrack(). The parameter to setFollow() is a list of Twitter IDs (Important: you have to convert screen names to twitter IDs yourself, first). More on that here: https://dev.twitter.com/docs/streaming-apis/parameters#follow
Note: Those users do not need to have given you permission: you are just seeing what they are showing to the world.
If you want to get all Twitter activity from a bunch of users then you need to use Twitter's Site Stream API. See example/sitestream.php in the Phirehose files for that. (I was the one who wrote that example, but I have never been able to test it: Site stream has been in closed beta since the Dawn Of Time, and it is so "closed" they even ignore our requests for a developer test account!)
The middle ground is the User Streams API. This allows you to get all Twitter activity but for just one user. If you can get each user to not just permission your app, but also give you their secret keys, you could run multiple Phirehose instances, one per user, and amalgamate all the data in a central database. This would be the poor-man's Site Streams :-)

Twitter API - iOS

I am currently creating an iOS app that integrates Twitter in such a way that it loads tweets into a UITableView. Currently I have gotten the tweets to load into the table view but I am having some issues with the names of the tweeters.
I can get the ID of the users. For example 1186989888 is the ID for DummyCode
Is there a way I can get from the ID, 1186989888 and have it return "Dummy Code". Which is DummyCode's screen name.
Does anyone know if this is possible with the Twitter API and iOS?
The Twitter users/lookup endpoint allows lookup by user_id, for up to 100 users at a time.
For a web-friendly view, you can also look up a single user by ID using a intent/user URL, e.g.
https://twitter.com/intent/user?user_id=1186989888

Scan Twitter Followers, API call issue

I want to get followers who are likely SPAM (With my algo like profile have no more than 10 twits, default profile picture etc..)
But suppose a profile have 1k followers, Its too hard to get all the data from that profile with 150 api call request.
Is there any other idea to do that ? Any third party api to get profile data ?
Thanks
It can be done with two API calls.
First, you want to get all the followers
https://api.twitter.com/1/followers/ids.json?screen_name=evilspammer
That will return up to 5,000 user IDs.
Then, post those IDs to users/lookup
You will then get back the full profile of all the users following your spammer.

Resources