Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

API in R & Ravelry

$
0
0

I'm trying to use the Ravelry API to do some data analysis and I'm having difficulties.

I'm modeling my code after this link but I'm afraid this blog may have been written before there were different kinds of permissions on the Ravelry API.

I have a OAuth 1.0a API with a text file with my username, key, and secret

library(httr)

# user_rav.txt contains API username and password 
credentials <- readLines("user_rav.txt")
names(credentials) <- c("user","access_key","secret_key")

OpenConnection <- function(credentials){
  # Args: login info for the Ravelry API
  # Returns oauth token
  # Open connection to Ravelry API and return token
  reqURL <- "https://www.ravelry.com/oauth/request_token"
  accessURL <- "https://www.ravelry.com/oauth/access_token"
  authURL <- "https://www.ravelry.com/oauth/authorize"

  ravelry.app <- oauth_app("ravelry", key=credentials["access_key"], 
                           secret=credentials["secret_key"])
  ravelry.urls <- oauth_endpoint(reqURL, authURL, accessURL)

  return(oauth1.0_token(ravelry.urls, ravelry.app))
}

# Quick test of API connection by getting connected user info
TestConnection <- function(ravelry.token) {
  # Arg: API token
  # Returns name of the user connected with this token
  test <- GET("https://api.ravelry.com/current_user.json", 
              config=config("token"=ravelry.token)) 
  print(content(test)$user$username)
}

ravelry.token <- OpenConnection(credentials)

The last line, "ravelry.token <- OpenConnection(credentials)" produces this error:

 Error in init_oauth1.0(self$endpoint, self$app, permission = self$params$permission,  : 
  Internal Server Error (HTTP 500). 

I've googled this error and, if you can believe it, there were only four hits. two weren't avaliable and the others were specific to an R package with the API that i'm not using.

I would appreciate any help.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>