Get access to the Twitter API: https://developer.twitter.com/en/apply-for-access
Create an APP, as documented here: https://developer.twitter.com/en/apps
Click on “Details”, then “Keys and tokens”
(The credentials listed above will not work)
Use the generated credentials as below:
|
library(httr) |
|
library(jsonlite) |
|
|
|
myapp = oauth_app("twitter", |
|
key="G87rxMsrngAiSkE6ZlWwXHd4n",secret="zSjjnEProRRFqDqEKNHWcOZU1CTQF4G2Q01yy7qqkwCeXJUDo1") |
|
sig = sign_oauth1.0(myapp, |
|
token = "1129684236733227008-EsgKImtzWxtvawBHPDBG01LKp9O413", |
|
token_secret = "4YKBlKXTgerRiocYWrTW8XTaVWd8O91TzPhE1UJ2AggCu") |
|
|
|
|
|
homeTL = GET("https://api.twitter.com/1.1/statuses/home_timeline.json", sig) |
|
json1 = content(homeTL) |
|
json2 = jsonlite::fromJSON(toJSON(json1)) |
|
json2[1:2,1:4] |
|
|
So where did the URL in GET come from?
The API Reference contains these instructions: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline
Like this:
Like Loading...
Related