Skip to content

Tweetinvi 3.0

Compare
Choose a tag to compare
@linvi linvi released this 30 Mar 16:11

Breaking Changes

  • Upload (major)
  • Tweet Length calculation
  • .NETStandard 3 changed to .NETStandard 4 (4.6 -> 4.6.1)
  • Extended mode is now used by default

Upload

Upload is the major change in the version. For more consistency and have an easier way to handle the different scenarios the library has been widely modified.

Upload Static

Upload now only has 2 endpoints : UploadBinary and UploadVideo.

Both endpoints can take a simple byte[] binary parameter.

var media = Upload.UploadBinary(binary);
var video = Upload.UploadVideo(binary);

You can also specify all the optional parameters as part of your request :

Optional Parameters

UploadStateChanged

Upload.UploadBinary(binary, new UploadOptionalParameters 
{
    UploadStateChanged = (stateChangedArgs) => 
    {
        Console.WriteLine($"{stateChangedArgs.State} : {stateChangedArgs.Percentage}%");
    }
});

WaitForTwitterProcessing

Ensure that when the media is returned by Tweetinvi it can directly be used in any new request. The reason for such a parameter is that videos and gifs have to be processed by Twitter beforehand the media can be used in a Tweet.

MediaType

MediaType = MediaType.VideoMp4

QueryMediaType

// To support any media type that would not be available as part 
// of the MediaType enum you can use
QueryMediaType = "video/mp4"

MediaCategory

MediaType = MediaType.Gif

QueryMediaCategory

// To support any media category that would not be available as part 
// of the MediaCategory enum you can use
QueryMediaType = "gif"

Timeout

Duration before cancelling a request.

MaxChunkSize

Custom binary chunk size to be sent to Twitter.

AdditionalOwnerIds

To specify who can use the uploaded media.

Customizing specific upload requests

You can add some custom parameters to the InitCustomRequestParameters and AppendCustomRequestParameters properties to support any new parameters.

Tweet

  • Improved support for unicode. This will now provide more accurate result for Prefix and Suffix as well as better length calculation.

  • The extended mode has been there for a while now and Tweetinvi will now be using this mode by default.

  • TweetinviConsts.MAX_TWEET_SIZE is now 280 and can now be modified by the developers.

  • As part of the Upload refactoring the methods PublishTweetWithMedia and PublishTweetWithVideo are no longer available use the parameters instead :

var media = Upload.UploadBinary(binary);

Tweet.PublishTweet("hello", new PublishTweetOptionalParameters()
{
    Medias = { media }
});

Tweet Length

Twitter has recently changed their algorithm to calculate the length of a Tweet. The changes involved are significant and therefore result in Tweetinvi algorithm to no longer be 100% aligned with their logic. Some improvements have been done for Unicode calculation but it is still no aligned on other changes.

As a result I would recommend that you use the official Twitter library to calculate a Tweet length.

The best approach to use this this, would be to create a simple node.js microservice that would simply return the tweet length. And you would consume this service via any protocol from your C# application.

List of breaking changes :

// NO LONGER EXIST

// ---- From a Tweet Instance
var length = tweet.CalculateLength(bool); 
var length = tweet.PublishedTweetLength;

// ---- From the Tweet static
var length = Tweet.Length();

// ---- From string or StringExtension
var length = string.TweetLength(...); // is now
var length = StringExtension.Length(...);

If nevertheless you want to keep using Tweetinvi's logic you can use the obsolete method from the StringExtension

// namespace Tweetinvi.Core.Extensions
var length = StringExtension.EstimateTweetLength(...);

At some point I will create a node.js project that you could use (probably after version 5.0).

Message

  • You can now access the MediaEntities of Messages

Streams

  • You can now define how you want to which TweetMode the stream will run with
  • Streams will now be run in extended mode by default.

Async

  • Async functions and tools have been modified to properly support Winforms projects.

.NETStandard 3 changed to .NETStandard 4

The new Xamarin projects are now targeting .NETStandard 4 and as a result Tweetinvi is now targeting .NETStandard 4. It also means that Tweetinvi will no longer support .NET Framework 4.6 but will now start the support at .NET Framework 4.6.1.

Strong Name

The library is strong named and all dependencies are also strongly named.

Semantic Versioning

To follow the globally used semantic versioning Tweetinvi 2.2 is now called Tweetinvi 3.0 and all future updates of the library with breaking changes will now be creating a new Major version.

Bug fixes

  • Account.UpdateAccountProfile is now properly updating if some values contain commas or special characters
  • Symbol entities now contain the $ character
  • Fixed bug that prevented some endpoints to properly upload binaries