Tweetinvi Update 0.9.8.0
Hi, I am proud to announce the long awaited of the new version of Tweetinvi. One of the reason of this delay is the creation of a completely new documentation.Another big announcement is the fact that the source code will be pushed on your beloved github for each major release! So please feel free to Fork it, Watch it and Star it.
Now let's see the improvements of this release!
Quick Overview
- Library Changes
- Twitter Lists
- Parameters
- User Suggestions
- Allow Direct Messages From Anyone
- Tweetinvi Container and custom obejcts
- Minor Updates
- Bug Fixes
Documentation
I have worked hard during this release to give you a new version of the documentation. It is still a work in progress but I think most of the critical information you might need should be available in this documentation.Please go on github to discover the new documentation, and please give some feedback!
Github
To be totally honest I think codeplex is a very good platform to manage an open source project, but let's be realistic, lots of developers looks into Github to find open source projects.As a first step in their direction I have decided to push the Source Code in a Git repository for each major release.
Click here to access the Tweetinvi Github Repository!
Library Changes
- The static TweetList class has been renamed TwitterList
- Please be aware of the changes affecting the methods that used "subjects" into their parameter objects (e.g. UserTimeline). More information.
- Tweet.Creator has been renamed Tweet.CreatedBy
- TwitterList.User has been renamed TwitterList.Owner
Twitter Lists
The most obvious update is that the static class TweetList has been renamed into TwitterList.This new version complete the implementation of all the methods related with Twitter Lists.
Please find examples for each of the different methods below. Please note that instead of list_id you can also use a list object, or the combination of a slug + owner.
// List CRUDvar newList = TwitterList.CreateList("<name>", PrivacyMode.Public, "<description>"); var list = TwitterList.GetExistingList(listId); var updatedList = TwitterList.UpdateList(listId, new TwitterListUpdateParameters {Description = "<new description>"}); var destroySucceeded = TwitterList.DestroyList(listId);
// Get the tweets available in the listsvar tweets = TwitterList.GetTweetsFromList(listId);
// Get Lists related with a uservar lists = TwitterList.GetUserOwnedLists(user); var lists = TwitterList.GetUserSubscribedLists(user);
var members = TwitterList.GetMembersOfList(listId); var memberAdded = TwitterList.AddMemberToList(listId, user); var memberRemoved = TwitterList.RemoveMemberFromList(listId, user); var isUserAMemberOfTheList = TwitterList.CheckIfUserIsAListMember(listId, user);
var subscribers = TwitterList.GetListSubscribers(listId); var loggedUserSuscribedToList = TwitterList.SubscribeLoggedUserToList(listId, loggedUser); var loggedUserUnSubsribedFromList = TwitterList.UnSubscribeLoggedUserFromList(listId, loggedUser); var isUserASubscriberOfTheList = TwitterList.CheckIfUserIsAListSubscriber(listId, user);
Parameters
New them up!
Parameters have been updated so that developers no longer need to use a factory to generate them.Any type of parameter can now be created using the "new" keyword easily. In addition, the parameters classes now live in Tweetinvi.Core.Parameters. This mean that you will no longer need to reference the Tweetinvi.Logic dll to new these up.
I hope this change will improve the readability and ease of access of 'advanced' requests.
// Example with update Account Settings// ***** Tweetinvi 0.9.7.1 - OLD *****var updateAccountParameter = Account.CreateUpdateAccountSettingsRequestParameters(); // ***** Tweetinvi 0.9.8.0 - NEW *****var updateAccountParameter = new AccountSettingsRequestParameters { Languages = new List<Language> { Language.English }};
Please find the objects you can now simply "new" up.
- IDENTIFIERS : TweetIdentifier, TwitterListIdentifier, UserIdentifier
- OBJECTS : Coordinates, GeoCode
- TIMELINE PARAMETERS : HomeTimelineParameters; UserTimelineParameters; MentionsTimelineParameters; RetweetsOfMeTimelineRequestParameter;
- SEARCH PARAMETERS : TweetSearchParameters; UserSearchParameters;
- ACCOUNT PARAMETERS : AccountSettingsRequestParameters;
- MESSAGE PARAMETERS : MessageGetLatestsReceivedRequestParameters; MessageGetLatestsSentRequestParameters;
- TWITTER LIST PARAMETERS : GetTweetsFromListParameters; TwitterListUpdateParameters
Parameters no longer store operation "subjects"
Parameters classes no longer contains the subject of a request. Instead they now only contain the parameters affecting the method.Let's see what this changes with an example:
var tweetinvi = User.GetUserFromScreenName("TweetinviAPI"); // ***** Tweetinvi 0.9.7.1 - OLD *****// We create a parameters class that contains the subject which is the user 'tweetinvi'.var userTimelineParameters = Timeline.CreateUserTimelineRequestParameter(tweetinvi) // The request is performed only with the parameters class.var tweets = Timeline.GetUserTimeline(userTimelineParameters); // ***** Tweetinvi 0.9.8.0 - NEW *****// We create parameters class that only contains the parameters that affect how the query is performed. // Not the subject of this query.var userTimelineParameters = new UserTimelineParameters { MaximumNumberOfTweetsToRetrieve = 100 }; // The request is performed by specifying both the subject (the user 'tweetinvi') and the parameters.var tweets = Timeline.GetUserTimeline(tweetinvi, userTimelineParameters);
User Suggestions
Developers can now access user's suggestions.var suggestedUsers = Account.GetSuggestedUsers("tweetinvi", Language.English); var suggestedCategories = Account.GetSuggestedCategories(Language.Japanese); var suggestedUsersWithHydratedStatus = Account.GetSuggestedUsersWithTheirLatestTweet("tweetinvi");
Allow direct messages from anyone
AccountSettings has a property AllowDirectMessage. The update functionality is not available to most developers and has therefore not been implemented to avoid confusion.Please have a look in this TwitterCommunity post to get more information.
Tweetinvi Container and custom objects{andchor:TweetinviContainer}
It is now possible to define custom objects that will be used and created by Tweetinvi instead of the default implementation provided by the library.It is now possible to change the dependency injection configuration of Tweetinvi before any operation has been executed.
``` c#
TweetinviContainer.BeforeRegistrationComplete += (sender, args) =>
{
var container = args.TweetinviContainer;
// Every method that return ITweet will now return a MyTweet
container.RegisterType<ITweet, MyTweet>();
};
```
Learn more
Minor Updates
- LoggedUser can now update their account settings.
- Tweet.Creator has been renamed Tweet.CreatedBy
- TwitterList.User has been renamed TwitterList.Owner
Bug Fixes
- Fixed MultiThreading issue that resulted in streams to behave incorrectly when stopped and restarted.
- SearchJson no longer throws a NullReferenceException when invoked from a thread that is not the main thread.
- UserStream is now correctly updating the list of friends.
- Fixed issue on Windows Phone resulting in MissingManifestResourceException when deployed on devices.
Update 0.9.8.1
In addition to the improvements made in 0.9.8.0, I have decided to create a new release that fixed long lasting issues within Tweetinvi.These fixes are not critical and just provide more information or more accuracy when they use Tweetinvi.
- FilteredStream have improved matching location and correctly tracks @mentions
- Search code has been updated to reflect the changes in the Twitter REST API responses. This will reduce the number of requests performed.
- Weak Events have been removed. Developers will now be responsible to remove the events from static objects themselves for the memory to be freed.
- Developers can now publish a tweet with media without having to re-upload the media. The clone method is still available if you want to publish the same media in multiple tweets.
- Added tests