Account Activity - Stream/Events¶
Now that users are subscribed to our webhook, Twitter will send events (through http requests) related to the subscribed users to our server.
These events will be raised by the Account Activity Stream.
We will use this stream and watch for specific events to take actions.
Account Activity Stream¶
To start listening to events coming from a user we will create an Account Activity Stream.
This stream will raise events when the webhook receives a request from Twitter for this specific user.
// the USER_ID specified must have been register for receiving the events
var accountActivityStream = accountActivityHandler.GetAccountActivityStream(USER_ID, "sandbox");
// we can now subscribe to various events from the stream
accountActivityStream.TweetCreated += (sender, tweetCreatedEvent) =>
{
Console.WriteLine("A tweet was created by USER_ID or a tweet mentioning USER_ID");
};
Events - Properties¶
Account Activity EventArgs contain information that explain what happened and why.
Property | Description |
---|---|
Json | The raw content of the http request |
InResultOf | Informs of the reason that caused the event to occur |
EventDate | Date when the event was received |
AccountUserId | For which user this event is for |
InResultOf
varies depending on the type of event. Each of the possibilities are listed in the section below.
Events¶
Event | Description |
---|---|
EventReceived | Twitter sent an event to the application, it is up for you to make sense out of it |
Event | InResultOf | Properties |
---|---|---|
TweetCreated A tweet related to the subscribed user has been created |
TweetCreatedRaisedInResultOf
|
|
TweetDeleted A tweet related to the subscribed user has been deleted |
TweetDeletedRaisedInResultOf
|
|
TweetFavorited A tweet related to the subscribed user was favorited |
TweetFavoritedRaisedInResultOf
|
|
UserFollowed The subscribed user followed or was followed by another user |
UserFollowedRaisedInResultOf
|
|
UserUnfollowed The subscribed user stopped following another user |
UserUnfollowedRaisedInResultOf
|
|
UserBlocked The subscribed user blocked another user |
UserBlockedRaisedInResultOf
|
|
UserUnblocked The subscribed user unblocked another user |
UserUnblockedRaisedInResultOf
|
|
UserMuted The subscribed user muted another user |
UserMutedRaisedInResultOf
|
|
UserUnmuted The subscribed user muted another user |
UserUnmutedRaisedInResultOf
|
|
MessageReceived The subscribed user received a message |
MessageReceivedInResultOf
|
|
MessageSent The subscribed user sent a message |
MessageSentInResultOf
|
|
UserIsTypingMessage The subscribed user is currently typing a message |
UserIsTypingMessageInResultOf
|
|
UserReadMessageConversation A user read the latest message of a conversation with the subscribed user |
UserReadMessageConversationInResultOf
|
|
UserRevokedAppPermissions The subscribed user revoked the application permissions. The user is now unsubsribed from the webhook |
UserRevokedAppPermissionsInResultOf
|
|
Special events
Event | Description |
---|---|
UnsupportedEventReceived | The event is not yet supported. Please open a ticket |
EventKnownButNotFullySupportedReceived | The event is supported but Tweetinvi could not understand why the event was received |
UnexpectedExceptionThrown | Something went wrong while processing an event |