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
Related
According to the official documentation, the related parameter is:
A comma-separated list of accounts related to the content of the shared URI.
But what exactly does it do? When the tweet is sent, the added twitter accounts are never included within the tweet message. And they do not receive a notification either about the tweet.
You will only see the related accounts after you've interacted with the tweet button.
Suggest additional Twitter usernames related to the Tweet as comma-separated values. Twitter may suggest these accounts to follow after the user posts their Tweet. You may provide a brief description of how the account relates to the Tweet with a URL-encoded comma and text after the username.
https://dev.twitter.com/web/tweet-button/web-intent
User hits the button, user posts tweet, user sees the accounts you added in the related field.
I am using devise for user authentication, how i can request from user, after clicking on sign in button, to enter sms code which is automaticaly sent to his mobile phone, for successful sign in.
I followed some instructions from internet, also i made twilio and got API key, but still no idea how to finish this.
We need more info for a complete answer (if possible).
First you need a sms provider (you seem to have chosen twilio).
Then you need code to be able to send sms using that provider.
https://www.twilio.com/blog/2012/02/adding-twilio-sms-messaging-to-your-rails-app.html
Then you need the logic. This is one way of doing it.
I am assuming you are using a database with login credentials.
Add a new table with 3 columns (adding another for primary key would not hurt), one columns for user_id, one column for a code, the next for a date.
Then when a user want to login create a code (numeric or not) and add the code to the table with current date and user_id, then send the sms to the users phone number and redirect the user to a page where he can enter the code. When he enters the code you compare it to your row in the database and validates it, having the date will make it easy to add a timeout of the code so that the user would have to enter the code in 60 seconds or what time you would prefer. You would have to send a id to the page where the user enters the sms code so you know which user it is, and that should of course be checked against the table. Using this approach makes it easy to track all tries the user has made.
A tip would be to add a limit on the numbers of sms per day/hour the user can use. Then he would be locked out for the rest of the day and would have to try again tomorrow. Otherwise someone with a user/pass could send thousands of request and forcing you to send out that many sms costing you a lot of money. That of course depend on is you debit the sms to the users account in some way..
Just wanted to mention it..
As my way....may be this process
create a dumy page for devise login .. in which take login details
Find users details from db and send him/her message
After submit on dummy page, next step will be to enter message otp code
after submit on this .... match otp of user with send otp
if it is correct than logged into device panel by api's
$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 :-)
I am trying to get checkin information of a user's particular friend in my application. In application, user authenticates to foursquare at the start which make me able to get his/her friend list.
I am getting the friend list with this API end point : https://api.foursquare.com/v2/users/self/friends. According to documentation it's response should include user objects which should have include checkins field but it seems there is no checkins field in the response. I can get other informations like first name, bio etc.
I also tried this API endpoint with user ID of friend which I want to get information of https://api.foursquare.com/v2/users/USER_ID/checkins but it returns an error states that I am not authorized for getting this information.
What am I doing wrong? Should I be authorized for this information since the information is about checkins of user's friends?
Thanks in advance.
Unfortunately this isn't a use case that's supported very well by the API. The way to see a list of check-ins of a particular user is through users/self/checkins. This will return the check-ins of the owner of the OAuth token that made the call.
As stated here https://developer.foursquare.com/docs/users/checkins:
USER_ID | self | For now, only self is supported
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.