Stream API for tweet like

api

#1

Hello

  1. is there any stream api for getting real time tweet like and unlike?

  2. I am getting error “exceeded connection limit for user twitter” when starting stream api.

Please Help

Thank you
Neel


#2

Yes, via User Streams.

You may only have one active connection to the Streaming API per app/IP. If you’ve constantly been connecting and reconnecting, you may also have been rate limited for connection attempts.


#3

Dear andypiper

How can we get a live stream if someone like my tweet?

I am using statuses/filter api, and in parameter I am passing follow: ‘my_user id’. But I am not getting any push when user leaves my tweet


#4

You’re not using User Streams.


#5

andypiper

Now I am using User stream api using following code.

But i am not able to get live streaming of another user?

Using User stream api i can get only one user live stream?

var T = new Twit({
    consumer_key: 'consumer_key',
    consumer_secret: 'consumer_secret',
    access_token: 'User_access_token',
    access_token_secret: 'User_access_token_secret',
    timeout_ms:           60*1000,  // optional HTTP request timeout to apply to all requests.
})
var stream = T.stream('user',  { stringify_friend_ids: true });

stream.on('user_event', function (eventMsg) {
    console.log('EventMsg : ' + JSON.stringify(eventMsg));
})


stream.on('tweet', function (tweet) {
    console.log('tweet : ' + JSON.stringify(tweet));
})

stream.on('favorite', function (tweet) {
    console.log('favorite : ' + JSON.stringify(tweet));
})

#6

That’s correct, user streams work for the authenticated user token.


#7

andypiper

I want a live stream of multiple user and User stream provides only one authorized user’s tweet like and tweet.


#8

andypiper

Any reply?


#9

I’ve explained how the API works, unfortunately there is no way to achieve what you are looking for.


#10

Hi @andypiper

The user stream is not sending me likes/favorite information. It does send me retweet events but not likes/favorites.
Is there any special filter parameter that I need to send with the stream url?

Thank


#11

No, there’s no parameter here. You should see favorite events for Tweets the authenticated user likes.

e.g.

{
  "event": "favorite",
  "created_at": "Wed Nov 01 13:53:34 +0000 2017",
  "source": { 
    "<user>"
  },
  "target": { 
    "<user>"
  },
  "target_object": {
    "<tweet>"
  }
}

#12

@andypiper what about likes that get received on the authenticated user’s tweets


#13

Yes, exactly the same except the source and target users are reversed. I’ve just tested this between two accounts and it is working as expected. It’s also the same for unfavorite events.


#14

@andypiper can you send me your sample url request please? I can’t seem to get like events at all. I do get other events like retweet etc but not likes.
I have been connecting using this: https://userstream.twitter.com/1.1/user.json
and using https://www.npmjs.com/package/twitter npm to stream.
And thanks for the swift responses. You’ve earned yourself a follower :metal:


#15

I’m simply connecting using twurl:

twurl -t -H userstream.twitter.com -A "Accept-encoding: none" "/1.1/user.json"

When one of my accounts likes or unlikes Tweets for the account I’ve authenticated in twurl, I see the events in the console.

Note that in the future, user streams will be replaced by the Account Activity API which is now in beta.


#16

Thanks a bunch.
I think the twitter NPM isn’t letting events payload through.
Yea, thanks for that I have applied for the AccountActivity API Beta Access🤞
One last question: are un-RT events possible to get as well?
Thanks


#17

There are no retweet or unretweet events. There are quoted_tweet events.


#18

thanks.


#19

I am not sure is it is slightly off topic but when I use statuses/filter API i receive chunks of tweets separated by \r\n the problem I am facing while consuming the chunks is that the JSONSerialization.jsonObject is throwing an error complaining about the json format. I am doing this using URLSession and not using Swifter library since there seems to be a few issues with that library with streaming. Plus i actually want to create a TWTRTweet object using the serialized json or json array. I am using Swift for ios and TwitterSDK.