Description Usage Arguments Details Value
safe_get_friends()
is a drop-in replacement for
rtweet::get_friends()
that automatically respects
Twitter API rate limits and coordinates use of
multiple Twitter access tokens that have been
registered with register_token()
. At the moment
you can only request the friends list of 15 or
fewer users in a single call.
1 | safe_get_friends(users, n = 5000, page = -1, verbose = FALSE, attempts = 5)
|
users |
Screen name or user ID of target user from which the user IDs of friends (accounts followed BY target user) will be retrieved. |
n |
Number of friends (user IDs) to return. Defaults to 5,000,
which is the maximum returned by a single API call. Users are
limited to 15 of these requests per 15 minutes. Twitter limits
the number of friends a user can have to 5,000. To follow more
than 5,000 accounts (to have more than 5 thousand "friends")
accounts must meet certain requirements (e.g., a certain ratio of
followers to friends). Consequently, the vast majority of users
follow fewer than five thousand accounts. This function has been
oriented accordingly (i.e., it assumes the maximum value of n is
5000). To return more than 5,000 friends for a single user, call
this function multiple times with requests after the first using
the |
page |
Default |
verbose |
Logical indicating whether or not to include output messages. Defaults to TRUE, which includes printing a success message for each inputted user. |
attempts |
How many times should we attempt to access the Twitter API before giving up? Defaults to 5. |
If no tokens have been registered with socialsampler
,
safe_get_friends()
will look for a token registered
with rtweet
and use that token instead, again
automatically respecting rate limits. If no tokens have
been registered with either socialsampler
or rtweet
,
you'll get an error.
An edgelist with columns:
from
: A character vector of node ids. This will match the
input format of users
. That is, if users
consists of
screen names, from
will consist of screen names. If
users
consists of user IDs, from
will as well.
to
: A character vector of node ids.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.