Closed DamienCormann closed 8 years ago
Please try the following code:
token <- RGA::authorize()
id <- ********** # without "ga:"
u <- paste0("https://www.googleapis.com/analytics/v3/data/ga?ids=ga:", id, "&start-date=2005-01-01&end-date=today&metrics=ga:sessions&dimensions=ga:date&filters=ga:sessions>0&max-results=1")
httr::GET(u, httr::config(token = token), httr::accept_json())
query <- list(ids = paste0("ga:", id), `start-date` = "2005-01-01", `end-date` = "today", metrics = "ga:sessions", dimensions = "ga:date", filters = "ga:sessions>0", `max-results` = 1)
httr::GET("https://www.googleapis.com/analytics/v3/data/ga", query = query, httr::config(token = token), httr::accept_json())
Hello Artem and thanks for your help here is the result:
token <- ga_token_RGA # copy my personal token to the token environement (the token was working previously)
id <- nnnnnnnn # actually a eight digit number
u <- paste0("https://www.googleapis.com/analytics/v3/data/ga?ids=ga:", id, "&start-date=2005-01-01&end-date=today&metrics=ga:sessions&dimensions=ga:date&filters=ga:sessions>0&max-results=1")
httr::GET(u, httr::config(token = token), httr::accept_json())
Error: is.request(y) is not TRUE
httr::GET("https://www.googleapis.com/analytics/v3/data/ga", query = query, httr::config(token = token), httr::accept_json())
Error: is.character(query) is not TRUE
kind regards
My code example works for me. So you have strange bug which not related with the RGA
package: it's httr
1.0.0 issue. You should send bug report to the httr
bug tracker. Now I can't reproduce you issue.
Below I provide the reproducible example code for you:
library(httr)
token <- oauth2.0_token(
endpoint = oauth_endpoints("google"),
app = oauth_app(appname = "app",
key = "144394141628-8m5i5icva7akegi3tp6215d9eg9o5cln.apps.googleusercontent.com",
secret = "wlFmhluHqTdZw6UG22h5A2nr"),
scope = "https://www.googleapis.com/auth/analytics.readonly",
cache = FALSE)
id <- 83639328
u <- paste0("https://www.googleapis.com/analytics/v3/data/ga?ids=ga:", id, "&start-date=2005-01-01&end-date=today&metrics=ga:sessions&dimensions=ga:date&filters=ga:sessions>0&max-results=1")
GET(u, config(token = token))
sessionInfo()
thanks for your help
I tested RGA
package on the CentOS 6.6 docker image. I didn't reproduce your issue.
After a library update from
RGA
library to 0.2.4, the below error message is returned by R when I fetch data:It happens when using RStudio or in batch mode.
This is my previously working code:
and
here is a example with traceback from a fresh session
as it seems to be
httr
related, I tried to devolutehttr
using:But
RGA
required version 1.0.0