Skip to content

Tweetinvi 0.9.13.0

Compare
Choose a tag to compare
@linvi linvi released this 13 Jun 06:56

Breaking changes

  • Coordinates are now lat/long (instead of long/lat) as per the ISO_6709.
  • Calling a method with invalid arguments will throw ArgumentException or ArgumentNullException. In release < 0.9.13.0, invalid arguments resulted in a null result to be returned.
  • IUser.ShowAllInlineMedia and IUserDTO.ShowAllInlineMedia have been removed.

Json Serialization

With the help of @tsconn23 we have started supporting json serialization of ITweetDTO and IUserDTO. Both have been tested and should work properly.

var json = JsonConvert.SerializeObject(tweet.TweetDTO);

You can learn more in the serialization wiki page.

As a reminder, Json serialization will be fully supported for version 1.1 (link).

RateLimits

RateLimits have been refactored entirely to use both the rate_limit_status endpoint available on the Twitter REST API and the headers received for each HttpRequest.

What it means for you is that the RateLimts will be more accurate than before when using the same credentials in concurrent running applications.

In addition to that we have added the newly added endpoint to the rate_limit_status.

Authentication Flow

The authentication flow has been improved to support more developers requirements.

AuthFlow.InitAuthenticationProcess can now take a new string parameter authenticationIdentifier. This 3rd parameter gives you the ability to specify the value of the callback url parameter authorization_id. In addition to this, IAuthenticationContext.Token has a new property AuthorizationUniqueIdentifier containing the value of this authorization_id parameter.

The benefit for the developers is that they can now store the Token.AuthorizationKey and Token.AuthorizationSecret inside their database with a primary key with a value equals to the authorization_id.

We also added a new overload of the CreateCredentialsFromVerifierCode taking a IAuthenticationToken as a parameter.

This will give you the ability to execute the following code :

var token = new AuthenticationToken()
{
    AuthorizationKey = "<from_db>",
    AuthorizationSecret = "<from_db>",
    ConsumerCredentials = creds
};

// And then instead of passing the AuthenticationContext, just pass the AuthenticationToken
var verifierCode = Request.Params.Get("oauth_verifier");
var userCreds = AuthFlow.CreateCredentialsFromVerifierCode(verifierCode, token);

Upload

Upload Status and Media Category

It is now possible to specify the media_category of an upload. This will allow developers to publish promoted content such as video via the amplify_video media category.

var media = Upload.UploadVideo(binary, "video/mp4", "amplify_video");

If you use amplify_video you will have to wait a certain amount of time before you can use the media. This information is available in the new GetMediaStatus(IMedia media, bool waitForStatusToBeAvailable = true) method.

The way to use this method is the following.

// The second parameter `waitForStatusToBeAvailable` set to true will make sure
// that tweetinvi waits few milliseconds before executing the query. This is required by Twitter.
var status = Upload.GetMediaStatus(media, true);

// If you want to wait yourself, you can use the media information as followed BEFORE executing
// the Upload.GetMediaStatus(media, false) method.
await TaskEx.Delay(media.UploadedMediaInfo.ProcessingInfo.CheckAfterInMilliseconds);

// When you have finally received the status, you have to wait for the upload 
// to have been completed to use your media in a Tweet.
while (status.ProcessingInfo.ProgressPercentage != 100)
{
    await TaskEx.Delay(1000);
    status = Upload.GetMediaStatus(media);
}

var tweet = Tweet.PublishTweet("Love tweetinvi promoted video!", new PublishTweetOptionalParameters()
{
    Medias = {media}
});

Upload Metadata

Tweetinvi now support the media/metadata/create endpoint. It gives you the ability to specify the alt text displayed for a media that you uploaded.

var success = Upload.AddMediaMetadata(new MediaMetadata((long)media.MediaId, "Alternative Text"));

Other Improvements

  • GeoSearchParameters now includes the accuracy parameter.
  • Added some documentation to the methods/properties.
  • SearchParameter.SearchResultType is now an optional parameter.

Bug Fixes

  • Fixed a bug that prevented user to publish tweets with media. This was the case for tweets with multiple media for example.
  • Fixed bug that sometimes prevented SearchTweets to being correctly executed when using GeoCode.
  • TwitterList had various endpoints that did now worked properly, including AddMultiple and DestroyMultiple. They have been fixed and improved.

Special thanks

I wanted to thanks everyone of you who reached us or helped us improve the library.
I would like to make a special note for :

  • @haseeb1431 who has become a new valuable member of the team.
  • @JoshKeegan for his great help on the issues while I was away.
  • @tsconn23 for sharing his code on serialization.