Description Usage Arguments Value References Examples
Create, add users, and destroy Twitter lists
1 2 3 4 5 6 7 8 9 10 |
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 |
Optional, numeric ID of list. |
slug |
Optional, list slug. |
token |
Expert use only. Use this to override authentication for
a single API call. In most cases you are better off changing the
default for all calls. See |
Response object from HTTP request.
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | ## Not run:
## CNN twitter accounts
users <- c("cnn", "cnnbrk", "cnni", "cnnpolitics", "cnnmoney",
"cnnnewsroom", "cnnspecreport", "CNNNewsource",
"CNNNSdigital", "CNNTonight")
## create CNN-accounts list with 9 total users
(cnn_lst <- post_list(users,
"cnn-accounts", description = "Official CNN accounts"))
## view list in browser
browseURL(sprintf("https://twitter.com/%s/lists/cnn-accounts",
rtweet:::api_screen_name()))
## search for more CNN users
cnn_users <- search_users("CNN", n = 200)
## filter and select more users to add to list
more_users <- cnn_users$screen_name[cnn_users$verified]
more_users <- setdiff(more_users, users)
more_users <- more_users[grepl("cnn", more_users, ignore.case = TRUE)]
## add more users to list- note: can only add up to 100 at a time
post_list(users = more_users, slug = "cnn-accounts")
## view updated list in browser (should be around 100 users)
browseURL(sprintf("https://twitter.com/%s/lists/cnn-accounts",
rtweet:::api_screen_name()))
## select users on list without "cnn" in their name field
drop_users <- cnn_users$screen_name[!grepl("cnn", cnn_users$screen_name, ignore.case = TRUE)]
## drop these users from the cnn list
post_list(users = drop_users, slug = "cnn-accounts",
destroy = TRUE)
## view updated list in browser (should be around 100 users)
browseURL(sprintf("https://twitter.com/%s/lists/cnn-accounts",
rtweet:::api_screen_name()))
## delete list entirely
post_list(slug = "cnn-accounts", destroy = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.