Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

Released: Tweetinvi 0.9.9.x (Aug 02, 2015)

$
0
0

Important

This release contains a large number of breaking changes regarding authentication and credentials.

With the intention of improving the web logic layer, I have also performed some important refactoring as well as changes in the parameters order. Please carefully read the changes section.

Overview

Breaking Changes

Tweetinvi 0.9.9.x introduces various break changes that were considered necessary as part of 4 different work items:
  • Implementation of Application Only Authentication
  • Refactor of Tweet Publish
  • Simplify the request of credentials via the Credentials Creator
  • Complete rewriting of the Authentication Process

Please read carefully the list of changes:

  • IMPORTANT : Auth.SetUserCredentials now takes the consumer key andconsumer secret as FIRST parameters. As opposed as the old `TwitterCredentials.SetCredentials` that took theaccess token and access token secret as first parameters.
  • Tweet are no longer being published with different methods. Only `Tweet.Publish` is now available. In addition we introduced a `TweetPublishParameters` that sets all additional information that you want the tweet to contain.
  • ITweet.Length is no longer calculating a tweet size before publishing it. Instead the static Tweet class now contains a `Length()` method calculating the size of a tweet based on publication parameters.
  • The static class `Tweetinvi.TwitterCredentials` has now become `Tweetinvi.Auth`.
  • `TwitterCredentials.SetCredentials` has now become `Auth.SetUserCredentials` when used with 4 credentials information.
  • `TwitterCredentials.SetCredentials` has now become `Auth.SetCredentials` when used with an ITwitterCredentials.
  • The `OAuthCredentials` class can now be new up and is now called `TwitterCredentials`
  • The new `TwitterCredentials` now contains additional information used for the login process or the application only authentication.

Windows 10

Windows 10 universal apps are now supported. Examplinvi.UniversalApp is a project that could inspire you to develop your own solution.

Example Projects

To help our community we have created 2 very basic projects using Tweetinvi.
  • Examplinvi.Web demonstrates how to authenticate a user with Twitter
  • Examplinvi.UniversalApp demonstrates how to set up a Windows 10 universal app with Tweetinvi

Publish Tweets

Publish Tweets has been completely refactored in order to: improve usability; allow developers to publish tweet with any combination; make publish future proof.

// You can still publish simple tweets as you did beforevar tweet = Tweet.PublishTweet("hello tweetinvi");

// But if you want more control, you will need to instantiate a PublishTweetOptionalParameters// Many new options have been added so feel free to try them!var tweet = Tweet.PublishTweet("hello tweetinvi", new PublishTweetOptionalParameters()
{
    PossiblySensitive = true
});

// As you can no longer create a temporary tweet that will be published, you will now rely on // Tweet.Length() to calculate the length of a tweet before it is publishedvar publishParameter = new PublishTweetParameters("hello tweetinvi", new PublishTweetOptionalParameters
{
    QuotedTweet = existingTweet
});

var publicationLength = Tweet.Length(publishParameter);

Application Only Authentication

Application only authentication is now supported by Tweetinvi. This feature is now available with the following code.

// If you do not have a Bearer Token stored
Auth.SetApplicationOnlyCredentials("CONSUMER_KEY", "CONSUMER_SECRET", true);

// Or
Auth.SetApplicationOnlyCredentials("CONSUMER_KEY", "CONSUMER_SECRET");
Auth.InitializeApplicationOnlyCredentials();

// If you already have a Bearer Tokenvar bearerToken = "some_value_that_you_stored_in_your_db";
Auth.SetApplicationOnlyCredentials("CONSUMER_KEY", "CONSUMER_SECRET", bearerToken);

Quoted Tweets

Tweetinvi now simulates the Quoted Tweet behavior introduced by the Twitter team. It allows to create a comment to another tweet.

new PublishTweetOptionalParameters
{
    QuotedTweet = existingTweet
});

Upload

Tweetinvi now officially supports chunked uploads and therefore video upload on Twitter.

// Simple Video Uploadvar media = Upload.UploadVideo(videoBinary);

Sometimes you will need to upload some content in multiple chunks. Here is how you can do this.
var uploader = Upload.CreateChunkedUploader();

// Initialize the uploadvar initSucceeded = uploader.Init("video/mp4", totalBinaryLength);

// Upload your different chunksvar success1 = uploader.Append(firstChunk);
var success2 = uploader.Append(secondChunk);

// When you have uploaded all your chunksvar media = uploader.Complete();

Proxy

With the refactor of the Web logic Tweetinvi is now capable of using the proxy settings on the following:
  • Authentication requests
  • Upload requests
Tweetinvi still does not support proxy for Streams.

Invalidate Token

As part of the Application Only Credentials, it is now possible for developers to invalidate a specific token using the following code:

var success = Auth.InvalidateCredentials(credentials);

OAuth

The `TwitterClientHandler` is a new class simplifying the implementation of custom `HttpHandlers`.
If you intend to add specific logic to `HttpHandlers` that is not supported by Tweetinvi please follow these instructions :

1. Create a sub-class of `TwitterClientHandler`.
2. Override `Task<HttpResponseMessage> SendAsync(ITwitterQuery twitterQuery, HttpRequestMessage request, CancellationToken cancellationToken)`.
3. Implement this method and update the request based on your context and the incoming ITwitterQuery.

Please note that you should not need to store any additional information in your custom `HttpHandler`. The ITwitterQuery should provide all the information you need to set up your request.

Bug Fixes

  • Fixed a 'bug' in FilteredStream that resulted in Tweetinvi to not return tweets which bounding box overlapped a location filter.
  • Fixed a bug that could prevent a query from executing in an ASP.NET project.

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>