Skip to content

Twitter Lists

linvi edited this page Mar 13, 2016 · 20 revisions

Overview

Lists in Twitter could have been called feeds. A List is an aggregation of multiple users timelines. Lists can be either public or private. When a list is public, other users can subscribe and see the tweets from your list.

Manage Lists

List identifiers

Contrary to other objects in Twitter, lists can be identified in 2 different ways. In Tweetinvi you will be able to use either of the following objects to as <list_identifier>.

  • Lists can be retrieved from their unique Identifier (Id).
  • Lists can also be retrieved by specifying the name (Slug) and the owner (User) of the list.
  • A TwitterList object itself.

Create a List

To begin working with lists, let's create our first list.

var list = TwitterList.CreateList("<name>", PrivacyMode.Public, "<description>");

Get a List

As mentioned just above we can get a List from its Id, Slug+Owner or from a TwitterListIdentifier.

// From the List Identifier (*long*)
var list = TwitterList.GetExistingList(<list_id>);

// From the Slug and Owner
var list = TwitterList.GetExistingList("<list_name>", <owner,id,screenName>);

// From an existing object (usually not populated)
var list = TwitterList.GetExistingList(<list_object>);

Update a List

You can also modify some details of a TwitterList.

var updateParameter = new TwitterListUpdateParameters()
{
    Name = "<new_name>",
    Description = "<new_description>",
    PrivacyMode = PrivacyMode.Public
};

// From a List object
var success = list.Update(updateParameter);

// From Static TwitterList
var success = TwitterList.UpdateList(list, updateParameter);

Delete a List

You can only delete a that the authenticatedUser user owns.

// From a List object
var success = list.Destroy();

// From Static TwitterList
var success = TwitterList.DestroyList(<list_identifier>);

Get Tweets from a List

This method can be accessed from a List object or the static class TwitterList.

// From a list object
var tweets = list.GetTweets();

// From static TwitterList
var tweets = TwitterList.GetTweetsFromList();

You can specify optional parameters to retrieve tweets from a list.

var getTweetsParameters = new GetTweetsFromListParameters()
{
    MaximumNumberOfTweetsToRetrieve = 100,
    IncludeRetweets = true,
    IncludeEntities = true,
    SinceId = 1784,
    MaxId = 487247
};

var tweets = list.GetTweets(getTweetsParameters);

Additional Features

Clone this wiki locally