Search code examples
phptwitter

Twitter API - Listen to a user's tweets in real-time


I am trying to listen to a number of users' (specific users) tweets in real-time using the Twitter API, but I have not been able to find any documentation regarding this. I have found lots of info about listening to tweets that use a certain hashtag or keyword but no info about listening to all tweets from certain users in real-time.

With the Twitter4J API I was able to specify a number of users, create a stream and then have a piece of code run whenever one of the users tweeted. How could I accomplish this with PHP?


Solution

  • From https://dev.twitter.com/streaming/reference/post/statuses/filter

    follow

    A comma-separated list of user IDs, indicating the users whose Tweets should be delivered on the stream.

    So, if you POST John,Paul,George,Ringo you will get a stream which includes:

    • Tweets created by the user.
    • Tweets which are retweeted by the user.
    • Replies to the user.
    • Retweets of the user.