OAuth with httr package and twitter API v1.1

1k views Asked by At

I'm trying to follow the demo in the httr package to authorize myself with twitter. However, using the code in the demo only produces this error:

Response [https://api.twitter.com/1/statuses/home_timeline.json]
  Status: 410
  Content-type: application/json; charset=utf-8
{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]} 

What in the code would need to be changed to allow it to work with Twitter API v1.1 (note that the key and token below are from the demo, but I use my own to produce the error above)?

I've also tried using the Roauth package, but it gives me the same error as here: strsplit error when attempting to access Fitbit with ROAuth

myapp <- oauth_app("twitter", key = "TYrWFPkFAkn4G5BbkWINYw")

sig <- sign_oauth1.0(myapp,
  token = "69133574-FZ9GJlJ57V0SVdNAzo71mQZSUrpUbiJZBVpDmbYkd",
  token_secret = Sys.getenv("TWITTER_ACCESS_SECRET"))

GET("https://api.twitter.com/1/statuses/home_timeline.json", sig)
1

There are 1 answers

0
petermeissner On BEST ANSWER

Try ... GET("https://api.twitter.com/1.1/statuses/home_timeline.json", sig) instead (substitute 1 by 1.1).