Hello,

Tweetinvi 5.0 was released 2 weeks ago and I wanted to bring this up here.

Tweetinvi 5.0 has been a major refactor and took more than a year to build the new bases to help developers build faster more reliable software. Tweetinvi does not just offer a simple interface to the API but also provide tools to simplify the development by offering solutions for:

Here are few code examples:

var authenticatedUser = await client.Users.GetAuthenticatedUserAsync();

var tweet = await client.Tweets.PublishTweetAsync("Hello tweetinvi world!");

var homeTimeline = await client.Timelines.GetHomeTimelineAsync();

// create a stream and listen to event
var sampleStream = client.Streams.CreateSampleStream();
sampleStream.TweetReceived += (s, args) => { Console.WriteLine(args.Tweet); };
await sampleStream.StartAsync();

Tweetinvi 5.0 now supports all the public Twitter API V2 so if you have never tried Tweetinvi it is time do it!
You can find the library on nuget: dotnet add package TweetinviAPI

Cheers,
Linvi

6 Likes

Hey @TweetinviApi,

I want to thank you here for all the things you’ve done for the .net (c#) Twitter community for years. I’ve been using Tweetinvi in our projects, and I’m very grateful for the developers like you taking their time keeping us on track! :1st_place_medal:

Keep up the good work :love_you_gesture:

Atakan

3 Likes

The path from version 4 to 5 is a steep step. Almost nothing works (like before). Is there a breaking change documentation somewhere?

Hi @midlifechrysler

I know this is a large breaking change. It was required because mainly because of the underlying behaviour of the SynchronizationContext with the async/await patterns and the different platforms implementations.

I appreciated that changing the code might not be trivial but most of the changes should only involve passing by a TwitterClient and calling the similar api.

For example:

// Tweetinvi 4.0
var tweet = Tweet.PublishTweet("My first tweet with Tweetinvi!");

// Tweetinvi 5.0
var tweet = await userClient.Tweets.PublishTweetAsync("My first tweet with Tweetinvi!");

I have taken a lot of time to build up the documentation for V5 to help the developers as well as reducing the learning curve. So please check it out here.

Thanks a lot for your response! The TwitterClient concept is very clear and helpful. Getting the authenticated user is no problem.
But I cannot create a user from a username or id,
Your sample is:

var tweetinviUser = await client.Users.GetUserAsync("tweetinviapi");

This throws: "cannot convert from ‘string’ to 'System.Collections.Generic.IEnumerable
The signature for this function is: Task<IUser> GetUsersAsync(IEnumerable usernames);
So I tried

user = await userClient.Users.GetUsersAsync(new string[] { "tweetinviapi"});

but this throws: CS0029 Cannot implicitly convert type ‘Tweetinvi.Models.IUser’ to ‘Tweetinvi.Models.IAuthenticatedUser’
Maybe I have messed up something in Linqpad, e.g. mix of older TweetInvi and 5.02?

But I can get tweets (for the authenticated user) without problems via

ISearchClient searchClient = new SearchClient(userClient);
var result = await userClient.Search.SearchTweetsAsync("Trump");
result.FirstOrDefault().FullText.Dump();

So how do I get a user by name?
Thanks in advance!!
Tom

I have just tried this code and it works properly on my side.
I would suggest to open an issue on github just to make sure I can reproduce your problem and fix it if there is one.

1 Like

Hi,

Thank you so much for the great work and documentation. I am currently trying to consume the Twitter sample stream api V2 using dotnet core 6.

I’m following the simple example from the docs:

// create a stream and listen to event
var sampleStream = client.StreamsV2.CreateSampleStream();

sampleStream.TweetReceived += (s, args) => { Console.WriteLine(args.Tweet); };

// start the stream
await sampleStream.StartAsync();

But am getting a exception of type TwitterException with the following details:
Any ideal what am doing wrong?

Exception:

Thanks
KOT