Tweetinvi 4.0
Breaking Changes
-
New version of the Direct Message API implies lots of changes, please read them in the
New Direct Message APIsection below -
UserEventArgs.Userhas changed toUserEventArgs.Target. This was needed as we introduced a way to differentiateSourceIdandTarget. -
Stream.TweetDeletedevent argument has changed to a new format to be compatible with new Account Activity Stream.
public class TweetDeletedEventArgs : EventArgs
{
public long TweetId { get; set; }
public long UserId { get; set; }
public long? Timestamp { get; set; }
}
AuthenticatedUser.GetLatestMessagesReceived->AuthenticatedUser.GetLatestMessages
New Direct Message API
Tweetinvi now supports the new Direct Message API.
Behind the scenes a lot has changed as, the queries to be performed are different as well as the object formats and the logic necessary to handle it.
A special note to say thank you to @JoshKeegan who has been the main developer to help bringing this feature to life.
What has changed
The IMessage interface has changed significantly:
Deleted properties
Twitter has reduced the number of information they in the message payload as a result some information that were current available does not exist anymore.
message.MessageDTOand has been replaced withmessage.EventDTOmessage.Senderis no longer available. You now only have access toSenderIdmessage.SenderScreenNameis no longer availablemessage.Recipientis no longer availablemessage.RecipientScreenNameis no longer availablemessage.IsMessagePublishedis no longer available
New properties
message.Appproperty now returns the information of the app used to create the messagemessage.InitiatedViaTweetIdmessage.InitiatedViaWelcomeMessageIdmessage.QuickReplyResponsemessage.AttachedMedia
Renamed properties
message.IsMessageDestroyed->message.IsDestroyed
Message static
Renamed methods
Message.GetLatestMessagesReceivedhas been renamedMessage.GetLatestMessagesas there is now only a single endpoint to get the latest messages.
PublishMessage
-
PublishMessageParameters constructoris now only taking a userId as second parameter (recipientId).screenNameis no longer supported. -
You can now publish a message with a Media attached to it (doc)
-
You can now publish a message with a Quick Response (doc)
GetLatestMessages example
// Messages Sent or received
var latestMessages = Message.GetLatestMessages(TweetinviConsts.MESSAGE_GET_COUNT, out string cursor);
// Check for a cursor having been returned, if not, there's no more results
if (cursor == null)
{
return;
}
var latestMessagesParameters = new GetMessagesParameters()
{
Count = 20,
Cursor = 20
};
var latestMessagesFromParameters = Message.GetLatestMessages(latestMessagesParameters, out cursor);
// ...
Limitations/Future improvements
Message.GetLatestMessageswill be improved with a new logic to manage cursor queries.
Twitter Webhooks, Account Activity and UserStream
Twitter is deprecating user stream and site stream. As a result, your app will no longer be able to create a stream to get live feed events for a specific user.
After the 18/08/2018, UserStream will no longer be available and will be replaced by AccountActivity.
AccountActivity will handle live events from Twitter by analyzing Twitter requests sent to your Webhook.
Important
To use webhooks with Tweetinvi, you will need to use the following nuget package :
Webhooks
A webhook is a http callback. You send to Twitter the url of an http server and Twitter will use that url to execute requests that will represent different events.
It means that you no longer need multiple streams to handle multiple users but just a single server that Twitter can communicate with to send you live updates.
Useful links :
Plugins
Plugins is a new way to register additional package that will work with Tweetinvi.
This is for example the case of the WebhooksModule that will later be created as a plugin because it is dependent with the Microsoft.AspNetCore.All package.
Plugins must be registered before any operation is executed by Tweetinvi.
// Before any operation with Tweetinvi you can add a plugin as followed.
Plugins.Add<WebhooksModule>();
Authenticated User
AuthenticatedUser.GetLatestMessagesReceivedhas been renamed toAuthenticatedUser.GetLatestMessagesas there is now only a single endpoint to get the latest messages.
Tweet
Tweet has now 2 new fields ReplyCount and QuoteCount.
Bug Fixes
- #690
GetPlaceTrendsAtno longer throws an exception if the query failed. It returns null as the others. - #711 Fixed publish tweet with multiple media ids
- #711 Fixed publish tweet with mutliple exclude reply user ids
- #711 Fixed upload of binaries with multiple owner ids
- #711 Search tweet with
GeoCodeis now properly behaving Trend.TweetVolumeproperty is now along