-
Notifications
You must be signed in to change notification settings - Fork 218
[DEPRECATED] User Streams
This type of stream is very useful. It allows you to get a wide variety of events related with a User
. For example you can get informed when the user publishes a message, a friend or simply when anyone you follow does. You can get informed for incoming messages, new followers, new lists, and I could continue... (but I won't!)
Below you can find a quick example demonstrating how to get notified when a new user is following the AuthenticatedUser
.
var stream = Stream.CreateUserStream();
stream.FollowedByUser += (sender, args) =>
{
Console.WriteLine("You have been followed by " + args.User);
};
stream.StartStream();
The UserStream has lots of different events that you can use to get all sort of information from twitter. Most of these events naming is enough to let you understand what they mean. I will therefore add some comments on 'advanced' events or events that need to be described.
Before enumerating the list of all the events, please be aware that differently from the other type of streams, a UserStream
does not receive any event from Twitter before it has been initialized. You can be notified that a UserStream has been initialized by listening to the following event.
// Version 0.9.10.x
us.StreamIsReady += (sender, args) =>
{
// After this point, we will receive events from Twitter
// And these events will be raised if you are listening to them
};
Here is a list of these events.
User Events (Learn more about users)
- AuthenticatedUserProfileUpdated
Tweet Events (Learn more about tweets)
- TweetCreatedByMe
- TweetCreatedByFriend - This event might not be raised if the user has more than 10.000 friends. (Learn more)
- TweetCreatedByAnyone
- TweetCreatedByAnyoneButMe
- TweetFavouritedByMe
- TweetFavouritedByAnyone
- TweetFavouritedByAnyoneButMe
- TweetUnFavouritedByMe
- TweetUnFavouritedByAnyone
- TweetUnFavouritedByAnyoneButMe
Message Events (Learn more about private messages)
- MessageSent
- MessageReceived
Friendship Events (Learn more about friendship)
- FollowedUser
- FollowedByUser
- UnFollowedUser
List Events (learn more about lists)
- ListCreated
- ListUpdated
- ListDestroyed
- AuthenticatedUserAddedMemberToList
- AuthenticatedUserAddedToListBy
- AuthenticatedUserRemovedMemberFromList
- AuthenticatedUserRemovedFromListBy
- AuthenticatedUserSubscribedToListCreatedBy
- UserSubscribedToListCreatedByMe
- AuthenticatedUserUnsubscribedToListCreatedBy
- UserUnsubscribedToListCreatedByMe
Block Events (Learn more about block)
- BlockedUser
- UnBlockedUser
Information Events
- FriendIdsReceived - Returns a collection of user ids who will be tracked by the stream.
- AccessRevoked - Informs that the user has revoked the access to the user account for the current application.
- WarningTooManyFollowersDetected - Learn more (twitter ref)
When a user stream starts, it sends the ids of all the users that will be tracked by the stream. If a user has more than 10.000 friends, it will return a random collection of 10.000 user ids. You can retrieve this information thanks to the event FriendIdsReceived
.
It means that if a user has more than 10.000 friends, the user stream will only provide notification for the 10.000 user ids contained in the list given by Twitter.
Having more than 10.000 friends should also result in Twitter raising the event WarningTooManyFollowersDetected
. As a result you can notify your user that he will not receive notifications for some of his friends.