Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

twitter

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?

like image 532
SamTebbs33 Avatar asked Nov 16 '15 19:11

SamTebbs33


2 Answers

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.
like image 63
Terence Eden Avatar answered Sep 18 '22 16:09

Terence Eden


Late response, but have you seen this?

https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/overview

Account Activity API

Overview

The Account Activity API provides you the ability to subscribe to realtime activities related to a user account via webhooks. This means that you can receive realtime Tweets, Direct Messages, and other account events from one or more of your owned or subscribed accounts through a single connection.

You will receive all related activities below for each user subscription on your webhook registration:

Activity types

  • Tweets (by user)
  • Tweet deletes (by user)
  • @mentions (of user)
  • Replies (to or from user)
  • Retweets (by user or of user)
  • Quote Tweets (by user or of user)
  • Retweets of Quoted Tweets (by user or of user)
  • Likes (by user or of user)
  • Follows (by user or of user)
  • Unfollows (by user)
  • Blocks (by user)
  • Unblocks (by user)
  • Mutes (by user)
  • Unmutes (by user) *Direct Messages sent (by user)
  • Direct Messages received (by user) *Typing indicators (to user)
  • Read receipts (to user)
  • Subscription revokes (by user)

Please note - We do not deliver home timeline data via the Account Activity API. Please use the GET statuses/home_timeline to pull this data.

like image 29
Monarch Wadia Avatar answered Sep 20 '22 16:09

Monarch Wadia