Skip to content

Tweetinvi 4.0

Compare
Choose a tag to compare
@linvi linvi released this 10 Aug 23:49
· 1 commit to 4.0 since this release

Breaking Changes

  • New version of the Direct Message API implies lots of changes, please read them in the New Direct Message API section below

  • UserEventArgs.User has changed to UserEventArgs.Target. This was needed as we introduced a way to differentiate SourceId and Target.

  • Stream.TweetDeleted event 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.MessageDTO and has been replaced with message.EventDTO
  • message.Sender is no longer available. You now only have access to SenderId
  • message.SenderScreenName is no longer available
  • message.Recipient is no longer available
  • message.RecipientScreenName is no longer available
  • message.IsMessagePublished is no longer available

New properties

  • message.App property now returns the information of the app used to create the message
  • message.InitiatedViaTweetId
  • message.InitiatedViaWelcomeMessageId
  • message.QuickReplyResponse
  • message.AttachedMedia

Renamed properties

  • message.IsMessageDestroyed -> message.IsDestroyed

Message static

Renamed methods

  • Message.GetLatestMessagesReceived has been renamed Message.GetLatestMessages as there is now only a single endpoint to get the latest messages.

PublishMessage

  • PublishMessageParameters constructor is now only taking a userId as second parameter (recipientId). screenName is 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.GetLatestMessages will 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 :

TweetinviAPI.WebhooksPlugin

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.GetLatestMessagesReceived has been renamed to AuthenticatedUser.GetLatestMessages as 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 GetPlaceTrendsAt no 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 GeoCode is now properly behaving
  • Trend.TweetVolume property is now a long