Learn R Programming

rtweet (version 1.2.1)

post_list: Manage Twitter lists

Description

Create, add users, and destroy Twitter lists

Usage

post_list(
  users = NULL,
  name = NULL,
  description = NULL,
  private = FALSE,
  destroy = FALSE,
  list_id = NULL,
  slug = NULL,
  token = NULL
)

Value

Response object from HTTP request.

Arguments

users

Character vectors of users to be added to list.

name

Name of new list to create.

description

Optional, description of list (single character string).

private

Logical indicating whether created list should be private. Defaults to false, meaning the list would be public. Not applicable if list already exists.

destroy

Logical indicating whether to delete a list. Either list_id or slug must be provided if destroy = TRUE.

list_id

Optional, numeric ID of list.

slug

Optional, list slug.

token

Use this to override authentication for a single API call. In many cases you are better off changing the default for all calls. See auth_as() for details.

References

Create: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-create Destroy: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-destroy Add users: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create, https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-create_all Remove users: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy, https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/create-manage-lists/api-reference/post-lists-members-destroy_all

Examples

Run this code
if (FALSE) {

## R related Twitter accounts
users <- c("_R_Foundation", "R_dev_news", "rweekly_live", "RConsortium", "rstats4ds",
  "icymi_r", "rstatstweet", "RLadiesGlobal")

## create r-accounts list with 8 total users
(r_lst <- post_list(users,
  "r-accounts", description = "R related accounts"))

## view list in browser at https://twitter.com//lists/r-accounts

## search for more rstats users
r_users <- search_users("rstats", n = 200)

## filter and select more users to add to list
more_users <- r_users$screen_name[r_users$verified]

## add more users to list- note: can only add up to 100 at a time
post_list(users = more_users, slug = "r-accounts")

## view updated list in browser (should be around 100 users)
## view list in browser at https://twitter.com//lists/r-accounts

drop_users <- "icymi_r"

## drop these users from the R list
post_list(users = drop_users, slug = "r-accounts",
  destroy = TRUE)

## view updated list in browser (should be around 100 users)
## view list in browser at https://twitter.com//lists/r-accounts

## delete list entirely
post_list(slug = "r-accounts", destroy = TRUE)

}

Run the code above in your browser using DataLab