Skip to content

Tweetinvi 0.9.14.0

Compare
Choose a tag to compare
@linvi linvi released this 23 Jun 10:42

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));
};