I am trying to retrieve Data from Marvel's API with R. Yet my code looks like this:
library(jsonlite) library(httr) library(digest) pb.txt <- Sys.time() pb.date <- as.POSIXct(pb.txt, tz = Sys.timezone) time.stamp = strtrim(format(pb.date, tz = "GMT", usetz = FALSE, "%Y-%m-%dT%H:%M:%SZ"), 24) public.key <- "***********************" private.key <- "**********************************" hash <- digest(paste0(time.stamp, private.key, public.key), algo = "md5") url <- GET(paste("http://gateway.marvel.com/v1/public/characters?ts=", time.stamp, "&apikey=", public.key, "&hash=", hash, sep = ""))
The Error I get here is after:
> content(url) $code [1] "InvalidCredentials" $message [1] "That hash, timestamp and key combination is invalid."
Beforehand the main problem was the timestamp, and I am still not sure if I calculate it the right way. Here is the Documentation for the API.
I hope anybody with more experiences with APIs could help me.