Tweetinvi 1.1
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 mainName
or all theNames
it is associated with. Account.GetMultipleRelationships
has been renamedAccount.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 FilterTweetsNotContainingGeoInformation
that 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 aGetUserFavoritesParameters
.- Tweetinvi custom
HttpMethod
enum now supports more Ads endpoint with newly addedDELETE
andPUT
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
- @haseeb1431 for his hard work on .NETCore