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

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