Description Usage Arguments Author(s) Examples
View source: R/search-tweets.R
searchTweets
connects to the REST API of Twitter and returns
recent tweets (usually no more than 5-7 days old) based on a supplied
search string. Note that this function will not return all tweets. As
explained in the documentation (https://dev.twitter.com/rest/public/search),
the goal of this API endpoint is relevance and not completeness.
1 2 3 |
q |
search query to issue to Twitter. It can contain Boolean operators. |
filename |
file where tweets will be stored (in json format) |
n |
maximum number of tweets to be downloaded |
oauth |
One of the following: either a list with details for an access token (see example below), a folder where OAuth tokens are stored, or a csv file with the format: consumer_key, consumer_secret, access_token, access_token_secret. |
until |
limit for the most recent tweet. The function will then returns tweets created before this date. Date should be formatted as YYYY-MM-DD. Keep in mind that the search index has a 7-day limit |
since_id |
id of the oldest tweet to be downloaded. Useful if, for example, we're only interested in getting tweets sent after a certain date. |
result_type |
specifies the type of results you would prefer to receive: "recent" (default), "popular" or "mixed". |
lang |
restricts tweets to the given language (e.g. "es") |
sleep |
numeric, number of seconds between API calls. Higher number will increase reliability of API calls; lower number will increase speed. |
verbose |
If TRUE, provides additional output in console about API rate limits |
Pablo Barbera P.Barbera@lse.ac.uk
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
## Creating OAuth token
my_oauth <- list(consumer_key = "CONSUMER_KEY",
consumer_secret = "CONSUMER_SECRET",
access_token="ACCESS_TOKEN",
access_token_secret = "ACCESS_TOKEN_SECRET")
## Download recent tweets by user "p_barbera"
searchTweets(q="twitter", filename="twitter-tweets.json",
n=200, oauth=my_oauth)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.