Skip to content

Releases: linvi/tweetinvi

Tweetinvi 5.0

05 Oct 00:55
Compare
Choose a tag to compare

Releases

5.0

Tweetinvi 5.0 is a major refactor of Tweetinvi. The new version introduces the TwitterClient which lets you perform all operations based on a fixed set of credentials. The change let us resolved various core problematics that arised with the evolution of the .NET Framework including async/await and ASP.NETCore execution contexts.

Here are some of the major changes.

  • Async/Await

Tweetinvi is now using the Async/Await pattern in its entire code base. This will help modern development and ease up ASPNET thread pool.

The TwitterClient gives you better control over who is executing a request. Also it gives developers the ability to pass the client through the code.

  • Twitter API V2

Support of all the endpoints of Twitter API V2!

Developers no longer have to search for endpoints available parameters. Tweetinvi contains all the parameters from the official documentation and all the parameters missing from the official documentation :D

Iterators are a new way to use paging in Twitter in a single and unique way. Developers no longer need to understand the 4 types of paging from Twitter API, Tweetinvi takes care of it for you!

Tweetinvi documentation has been at the core of the new version.

  • The new documentation should explain provide examples for all the bits and pieces you can find in the Tweetinvi library.
  • All publicly available code has been annotated to explain what each method do and what they return.

A lot of work has been done to simplify the Account Activity process and make it as easy as possible for developers to start using it.

  • .NET Compatibility

Tweetinvi 5.0 has been built for .NETStandard 1.4 and .NETStandard 2.0 which should make it compatible for most of the existing .NET environments!

  • Support for missing endpoints

Some endpoints were missing from the library. All endpoints in the Twitter documentation are now officially supported.

Exceptions have never been a strong part of Tweetinvi. This has changed and Tweetinvi is now throwing a very limited set of Exceptions.

  • Better support for special cases

Twitter API endpoints are managing response formats, status codes, headers, response, error messages in different ways. Tweetinvi now takes care of all the special cases for you and handle these cases as you would expect hiding the complexity behind a simple API.

  • Bug Fixes

5.0 was also a chance to fix a long list of bugs, including multithreading, missing data, unhandled cases, non matching criteria and many more...

  • Integration Tests

Tweetinvi 5.0 uses integration tests to verify that the code base is properly working. Not only does this give us a better view on the state of the library but also let you discover how to use the library!

  • And much more

Performance improvements, upload support, parameters validation, namespaces/code cleanup, dependencies updates, .NETCore support...

Tweetinvi 5.0 is the result of more than a year of work, countless hours and more than 350 commits so I hope you will appreciate using the new version.

I take this opportunity to thanks @JoshKeegan for his special contributions to the project.

I look forward to hearing your feedback!

Tweetinvi 4.0

10 Aug 23:49
Compare
Choose a tag to compare

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

Tweetinvi 3.0

30 Mar 16:11
Compare
Choose a tag to compare

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

Tweetinvi 2.1

30 Oct 00:35
Compare
Choose a tag to compare

Async

TweetinviSettings is now being set with the same settings used by the Thread invoking any async action with Sync.ExecuteTaskAsync.

TweetinviSettings.TweetMode = TweetMode.Compat;

var homeTimeline = await Sync.ExecuteTaskAsync(() => 
{
    // Here the tweets will be retrieved with TweetMode.Compat
    // because the calling thread uses such config
    return Timeline.GetHomeTimeline();
});

Custom Http Headers

You can now add your own http headers to any query performed by the library using TweetinviEvents.

// Use the gzip compression

TweetinviEvents.QueryBeforeExecute += (e, args) => 
{
    args.TwitterQuery.CustomHeaders.Add("Accept-Encoding", "gzip");
}

Emoji and Tweet Length

Tweetinvi length calculation used to check for character size based on the number of bytes that each grapheme required.

With further investigation it appeared that Twitter is not handling some Emojis the same way.

I have therefore tried to improve the logic to match the logic from Twitter.

This is particularly relevant for some of the new extended tweets properties like Suffix and DisplayRange.

If you encounter some mismatch between what Twitter is returning and what Tweetinvi returns in terms of a Tweet Text please open an issue.

Upload

When uploading content you can now pick the type of content you want to send from the UploadMediaCategory enum.

In addition to this, Upload.UploadVideo is no longer using amplify_video by default but tweet_video
which is the only one supporting video larger than 15mb.

A new static method has been added to Upload so that you can specify the type of media category you wish to use.

IMedia UploadVideo(byte[] binary, UploadMediaCategory mediaCategory)

Exception Handler

TweetinviEvents.QueryAfterExecute will now provide the actual exception if any occurred.

Previously only the status code of the error was returned. This should simplify error logging for some developers.

TweetinviEvents.QueryAfterExecute += (e, args) => 
{
     var exception = args.Exception;
    // Do whatever you want with it :)
};

List memberships

List memberships endpoint is now part of the library :

var twitterMemberships = TwitterList.GetUserListMemberships("twitter");

Examplinvi

All the example projects have been retested, upgraded and description have been added.
All the projects compatible with Visual Studio for Mac have also been tested.

The Universal App project has been tested on Raspberry Pi 3 with Windows 10 iot.

You will also find 2 new projects for

  • WPF
  • Winforms

.NETCore dll not found exceptions

In order for the library to be the most compatible with the different application types and versions of .NET, I have removed the dependency to System.Type.Primitives

Bug Fixes

  • Tweet.Suffix for tweets with a display range length of 0 is now properly returned.
  • AuthFlow.InitAuthenticationProcess is now supporting oauth_callback_confirmed being
    returned as a string.
  • TwitterList.GetExistingList is now properly validating the provided parameters (either the id or slugname needs to be provided).

Tweetinvi 2.0

18 Jun 17:24
Compare
Choose a tag to compare

From PCL to .NETStandard

Tweetinvi has been a Portable Class Library (PCL) since 2014 in order to help C# developers to use Twitter in Mono and then in Xamarin.

With .NetStandard PCL will progressively being migrated to .NETStandard libraries and this is why Tweetinvi is no longer a PCL.

New targets: .NETStandard 1.3 and .NETFramework 4.6

During this migration I had to make choices regarding the target. Initially I wanted to keep targeting .NETStandard 1.0 and .NETFramwork 4.0.

Unfortunately I was not able to do so and the minimum target of Tweetinvi 2.0 and later will be .NETStandard 1.3 and .NETFramework 4.6.

New dependency

  • Nito.AsyncEx.Context is a new dependency of Tweetinvi. This library is used to ensure that async functions provided by Tweetinvi correctly "continue" on the same invoker thread.

Removed dependencies

  • Microsoft.Bcl.Async is no longer a nuget dependency as async has been integrated in .NETFramework 4.5.

Sample projects

The new solution includes various new sample projects that you can reuse to start your project.
At the time of this release you can find the following :

Other samples will come in the future. I am currently thinking of WPF and RaspberryPi.

Bug Fixed

A critical bug regarding async and multithreading where the Task completion callback Thread was not the calling thread. This issue was happening in application without any SynchronizationContext like console application.

You can read more about it on the bug at : #473.

ASP.NET (.NET Framework) considerations

By default Tweetinvi should install properly to ALL type of projects with the proper .NET targets.

In some cases the installation of the System.Net.Http and System.Runtime.Serialization.Primitives dependencies can result in dependency conflicts over the version of the DLL to use.

If you encounter an Exception stating that the library System.Net.Http or System.Runtime.Serialization.Primitives could not be found, please add the following configuration in your web.config.

<dependentAssembly>
	<assemblyIdentity name="System.Runtime.Serialization.Primitives" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
	<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
</dependentAssembly>

<dependentAssembly>
	<assemblyIdentity name="System.Net.Http" publicKeyToken="B03F5F7F11D50A3A" culture="neutral" />
	<bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.1.1.1" />
</dependentAssembly> 

These lines should be added under the <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">.

Tweetinvi 1.3

12 Jun 12:53
Compare
Choose a tag to compare

Breaking Changes

  • Proxy configuration has changed. To make sure that any username/password can be used in the proxy, you have now to configure your proxy with the following code:
var proxyConfig = new ProxyConfig("http://192.168.1.1", new NetworkCredential("username", "password"));
TweetinviConfig.CurrentThreadSettings.ProxyConfig = proxyConfig;
  • Improved the selection of entities to provide based on whether a Tweet mode is compat or extended. The entities provided will now be unique will provide accurate indices based on the mode of the Tweet. A TweetMode property has been added to the Tweet to let the users know what type of Tweet they are using.

  • Streams are now matching QuotedTweets.

  • Fixed typo : SubsribeToList has been updated to SubscribeToList

Extended Tweets

  • The exclude_reply_user_ids parameter has now been added to the parameters for publishing a new Tweet. This parameter will be used if the auto_populate_reply_metadata is set to false.

  • Tweets contains a new property TweetMode allowing the developers to know how a Tweet has been retrieved.

Streams

  • Streams are now properly matching QuotedTweets. You can get access to QuotedTweet matching in the MatchingTweetReceived.
var fs = Stream.CreateFilteredStream();

fs.MatchingTweetReceived += (sender, args) =>
{
    var quotedTweetMatchedOn = args.QuotedTweetMatchOn;
    var matchingTracks = args.QuotedTweetMatchingTracks;
    var matchingFollowers = args.QuotedTweetMatchingFollowers;
    var matchingLocations = args.QuotedTweetMatchingLocations;
};
  • FilteredStreams now provide a new CheckIfTweetMatchesStreamFilters that allow the developers to know on what a Tweet is matching some criteria.

  • Streams have a new event called KeepAliveReceived that inform the developers that Twitter has sent a KeepAlive event.

Auth

  • InitializeApplicationBearer now returns a boolean indicating whether the operation has been a success.

Advanced

  • It is now possible for developers to generate a query object (ITwitterRequestParameters) that can be used to transfer a query to another client securely. The query will be created and signed on the server and executed on another consumer.

You can find this method on the TwitterAccessor

ITwitterRequestParameters GenerateTwitterRequestParameters(string url, HttpMethod method, ITwitterCredentials credentials, HttpContent httpContent)

Bug Fixes

  • [STREAM] Infinite Timeout is properly assigned to Streams
  • [STREAM] UserStream for users with more than 10k users properly handle the FOLLOWS_OVER_LIMIT event.
  • [TWEET] The algorithm to calculate the Tweet Lenght is now properly handling - in urls.
  • [CREDENTIALS][THREADING] Fixed issue that could result in invalid credentials to be used when using multiple concurrent threads.

Tweetinvi 1.2

14 Dec 16:31
Compare
Choose a tag to compare

Breaking Changes

  • IMPORTANT : Please read if you use Tweetinvi in multiple threads with multiple credentials. Thread credentials has slightly changed to fix a bug that resulted in the incorrect credentials to be picked in some cases. Read more in the Thread Credentials section
  • Only the Extended Tweets are now available in the ITweet.Entities property. as opposed to before when the property was returning both Extended Entities AND Legacy Entities

Nuget

With the addition of .NETCore to nuget targets for the library, some people started to experience problems regarding the dependencies that were added based on their platforms specifically for Xamarin and Mono. We are pleased to announce that this has been fixed and in addition projects with classical .NET Framework will be able to use Autofac >= 3.5.2 again.

Streams

TweetEventArgs now return an ITweet and its associated json to simplify the life of developers!

Custom Accept Headers

To improve the flexibility of Tweetinvi, ITwitterQuery now provide a new property AcceptHeaders that you can update to customize the Accept headers that will be used to execute the HttpRequest.

Messages

You can now access private message entities via the IMessage.Entities property.

Upload

A new method allow you to rely on Tweetinvi to synchronously wait for a media to be uploaded and processed by the Twitter Upload API.

var binary = File.ReadAllBytes(@"C:\Users\linvi\Pictures\sample_video.mp4");
var media = Upload.UploadVideo(binary, mediaCategory: "amplify_video");
// The media cannot be used for the moment.

var mediaWithMetadata = Upload.WaitForMediaProcessingToGetAllMetadata(media);

// Now we can access the media's metadata.
var videoType = mediaWithMetadata.UploadedMediaInfo.VideoDetails.VideoType;

Thread Credentials

This topic is about threads and is slightly more technical than usual, please read attentively.

You can be affected by this change...

  • If you run an application with multiple credentials.
  • If you use these different credentials on multiple threads.
  • If you use object instances methods (ITweet, IUser, IMessage...)
  • If object instances created in a thread T1 are being used to invoke methods from another thread T2 (T1 and T2 having a different set of credentials)

Technical Explanation

Most developers uses Auth.SetUserCredentials in order to set the credentials used within the current running thread. Any object (tweet, user, message...) created in the context of this thread are being constructed with injected controllers/factories/helpers.

Before version 1.2 a newly created object was storing a controller that helped him execute any operation related with this object type (e.g. ITweet objects are capable of invoking a PublishRetweet() method).

The problem was that the controller within the newly object had an indirect reference to the credentials of the thread used for the creation of the object.

Therefore invoking tweet.PublishRetweet in a thread T2 different from the constructor thread T1, incorrectly resulted in the credentials of T1 to be used to run PublishRetweet whilst developers would have expected the credentials of T2 to be used to run the instance method.

In version 1.2 PublishRetweet correctly uses the running thread T2 credentials.

Some code to explain

ITweet tweet = null;
var T1 = new Thread(() =>
{
    // We initialize the T1 credentials
    Auth.SetUserCredentials(creds1);

    // We have a tweet that was created with T1
    tweet = Tweet.PublishTweet("hello");
});

T1.Start();

// The tweet variable is now an instance of ITweet
T1.Join();

// We initialize the credentials of the main thread T2
Auth.SetUserCredentials(creds2);

// Here is where the bug happened before 1.2
// PublishRetweet was running with creds1 (T1) instead of creds2
// In version 1.2, this operation will be executed with creds2
tweet.PublishRetweet(); 

Other

  • Added a new field PublishTweetParameters.ExcludeReplyUserIds
  • Autofac >= 3.5.2 dependency is back
  • Added support of 308 status code for TON Api
  • UploadProcessingInfo is now an enum that help developers to know the current stage of an upload.
  • Extended Tweets have added new HTTP error codes. They are now supported by the library.

Bug Fixes

  • Extended Tweet suffix length has been updated to properly reflect the value from Twitter
  • QuotedTweet throwing an error for being > 140 characters with Extended Tweets

Tweetinvi 1.1

22 Sep 02:19
Compare
Choose a tag to compare

Breaking Changes

  • Language static class has been improved so that each language code is now associated to only one Language enum. The enum has a LanguageAttribute that you can use to retrieve its main Name or all the Names it is associated with.
  • Account.GetMultipleRelationships has been renamed Account.GetRelationshipsWith.

.NET Core

Tweetinvi for .NET Core is now available through the TweetinviApi nuget package.

Serialization and Deserialization

Tweetinvi now provide a very simple tool to serialize and deserialize objects.

The JsonSerializer is a new static class that will give you the ability to serialize any Tweetinvi model into a string. It also give you the ability to deserialize this same string back into the object type or in its DTO implementation.

// Get tweet from Twitter
ITweet tweet = Tweet.GetTweet(778303039111368706);

// Serialize Tweet
string jsonTweet = JsonSerializer.ToJson(tweet);

// Deserialize Tweet into ITweet
ITweet deserializedTweet = JsonSerializer.ConvertJsonTo<ITweet>(jsonTweet);

// Deserialize Tweet into DTO
ITweetDTO deserializedTweetDTO = JsonSerializer.ConvertJsonTo<ITweetDTO>(jsonTweet);

Note that these classes are extension methods.

// Same code with extension methods.

ITweet tweet = Tweet.GetTweet(778303039111368706);
string jsonTweet = tweet.ToJson();
ITweet deserializedTweet = jsonTweet.ConvertJsonTo<ITweet>();
ITweetDTO deserializedTweetDTO = jsonTweet.ConvertJsonTo<ITweetDTO>();

Language

The Language enum has been improved to provide more information to the users. Its associated LanguageAttribute now gives you the following information :

  • Name : The main name of the language.
  • Names : All the names associated with this language.
  • Code : The main code for this language.
  • Codes : All the codes associated with this language.

Language and LanguageFilter

Twitter does not allow developers to filter tweets based on all the existing Languages.
The Language enum that was used previously by Tweetinvi to filter streams and searches has been replaced by the LanguageFilter enum.

ITweet.Language has not been affected and is still using the Language enum.

Language lang = args.Tweet.Language;

Search

// Get only French tweets
var tweets = Search.SearchTweets(new SearchTweetsParameters("tweetinvi")
{
    Lang = LanguageFilter.French
});

Stream

// Get only French tweets
stream.AddTweetLanguageFilter(LanguageFilter.French);

// Remove the French filter
stream.RemoveTweetLanguageFilter(LanguageFilter.French);

Search Geo Strict Mode

Tweetinvi search now contains a new parameter FilterTweetsNotContainingGeoInformationthat give you the ability to only receive tweets that contain a Place or Coordinates when requesting tweets published at a specific Geo location.

var tweets = Search.SearchTweets(new SearchTweetsParameters("tweetinvi")
{
    GeoCode = new GeoCode(/*...*/),
    FilterTweetsNotContainingGeoInformation = true
});

Download binary

This feature has been provided for a future version of Twitter. Currently Twitter does protect some binary downloads with OAuth. This new feature allow you to download such binaries.

You can for example try to use it to download private messages media.

IMPORTANT NOTE: this is not supported by Twitter and you can receive an exception or the returned binary can be invalid.

var binary = TwitterAccessor.DownloadBinary("https://twitter.com/...");

Minor Improvements

  • Improve quoted tweets generated text.
  • GetFavoritesAsync now has an overload taking a GetUserFavoritesParameters.
  • Tweetinvi custom HttpMethod enum now supports more Ads endpoint with newly added DELETE and PUT actions.

Bug Fixes

  • Stream could throw an unhandled exception if it TimeOut. This exception will no longer be thrown.
  • Updated exception thrown when a user has not set up its credentials before using any Tweetinvi endpoint.
  • ITweet.Media.Variants.ContentType is now properly populated.
  • UpdateList is no longer throwing an Unauthorized exception.

Thanks

Tweetinvi 1.0

05 Jul 19:40
Compare
Choose a tag to compare

A bit of history

After 4 years of development we are finally releasing the first major version.
We've communicated with many of you, participated in your projects in order to understand how to guide this project. Therefore I would like to make a big thank you to all of you who have participated to make this release possible.

That said, I hope you will love this latest release.

Breaking Changes

  • Global Namespace refactor. Please consider reading the new namespace documentation.
  • Generate Parameters have been deleted. Use new Parameter() instead. (learn more).
  • Publish methods taking Tweet or Message have now been removed. (learn more).

Signed Libraries

Tweetinvi libraries released will now be signed by certificates. This will allow companies to ensure that the library is an "official" build.

Accessibility and consistency

Our focus for version 1.0 was to improve the library to make it easier and faster to use. We wanted to have a global library that made sense. With this goal in mind we have improved lots of classes/interfaces namespaces, we have removed some redundant methods and finally we have improved the in code documentation.

Namespace complete refactor

For this release 1.0, we wanted to make sure that users were able to have a clear overview of the namespaces they need when using the library.

We have therefore greatly reduced the number of using statement required and consolidated them into major comprehensive groups.

You can learn more about the namespaces in the documentation.

Generate parameter methods deleted

All the generate methods that were used to create parameters have now been removed to promote the ability for developers to create the same parameters using the new keyword.

List of changes :

  • User.GenerateUserIdentifierFromId is no longer available. Please use new UserIdentifier instead.
  • Geo.GenerateGeoCode is no longer available. Please use new GeoCode instead.
  • Tweet.GenerateOEmbedTweet has been renamed Tweet.GetOEmbedTweet
  • Message.CreateGetLatestsReceivedRequestParameter has been removed. Use new MessagesReceivedParameters() instead.
  • Message.CreateGetLatestsSentRequestParameter has been removed. Use new MessagesSentParameters() instead.

Publish methods overloads deleted

For historic reasons, Tweetinvi kept using old methods that allowed developers to create a local (and unpublished) version Tweet or a Message and then actually publish it based on some of its properties.

To make it clear of which properties Tweetinvi is using we have now deleted such methods. Developers will be able to publish using Parameters objects containing all the available parameters that can be use to define how to publish.

Below you can find a list of changes :

  • Tweet.Publish(ITweet) no longer exist. Use Tweet.PublishTweet(IPublishTweetParameters) instead
  • new PublishMessageParameters(IMessageDTO) no longer exists. Use the other constructor overloads instead.

Tweetinvi 0.9.14.0

23 Jun 10:42
Compare
Choose a tag to compare

Extended Tweets

Extended Tweet should be released in the coming months. Version 0.9.14.0 is a first version trying to address most of the concepts introduced by this new type of Tweets.

Compatibility

First of all I would like to mention that Tweetinvi support of Extended Tweet does not mean that it does no longer support the current version of the Twitter API.

The code has been thought of so that Tweetinvi can handle both versions safely.

New properties

ITweet includes new properties that you can use to extract the information from an extended tweet.

var tweet = Tweet.PublishTweet("@tweetinviapi forever! pic.twitter.com/42");
var fullText = tweet.FullText; // @tweetinviapi forever!
var prefix_or_mentions = tweet.Prefix; // @tweetinviapi
var content = tweet.Text; // forever!
var suffix = tweet.Suffix; // pic.twitter.com/42

You can also access some other metadata like :

int[] tweet.DisplayTextRange; // Contains the location of the text to display (content).
IExtendedTweet tweet.ExtendedTweet;  // Contains all the information specific to extended tweets.

Tweet Mode

Twitter introduced a TweetMode that is either compat or extended. To make it simpler for developers, they will be able to set this value directly from the TweetinviConfig for the lifetime of a thread of for the entire application.

TweetinviConfig.CurrentThreadSettings.TweetMode = TweetMode.Extended;

Note that by default this value will be null. When not set, Tweetinvi will not add the tweet_mode parameter to any of the endpoints that can use it.

In addition to this, the auto_populate_reply_metadata has been added to the PublishTweetOptionalParameters class.

Tweet parts

To preview how a string will be divided you can use the new string extension method TweetParts().

string tweet = "@tweetinviapi Amazing!";
ITweetParts tweetParts = tweet.TweetParts();

string prefix = tweetParts.Prefix;
string content = tweetParts.Content;
int twitterLength = tweetParts.Content.TweetLength();
string[] mentions = tweetParts.Mentions;

NOTE : TweetParts are only to be used with text that is intended to be used with tweet_mode extended and in reply to another tweet.

Extended Entities

The extended entities will be merged into the Entities property automatically.

Minor Changes

Some developers want their app to work in an uncontrolled environment like mobile phones. In such environment, we do not have any control in regards to the DateTime/Timezone configuration. As Twitter requires its request to be signed with a UTC datetime, developers can now decide how they want to retrieve this information (accessing the value from an external website for example).

TweetinviConfig.CurrentThreadSettings.GetUtcDateTime = () =>
{
    return DateTime.UtcNow.Subtract(TimeSpan.FromHours(1));
};