从R-Bloggers运行R Instagram示例出错?

时间:2016-08-07 17:51:48

标签: r instagram

我在这里运行R Instagram查询示例时遇到错误:https://www.r-bloggers.com/analyze-instagram-with-r/

我猜它与我的Instagram客户端有关(状态是" Sandbox Mode"),但不知道该怎么做。这是R代码和输出:

代码:

require(RCurl)
require(httr)
full_url <- oauth_callback()
full_url <- gsub("(.*localhost:[0-9]{1,5}/).*", x=full_url, replacement="\1")
print(full_url)


app_name <- "teamusainrio"
client_id <- "a36424058cdf424c8e8b2d5cc2af1b15"
client_secret <- "398863caad6a4171ad10eb201870065b"
scope = "basic"

instagram <- oauth_endpoint(
  authorize = "https://api.instagram.com/oauth/authorize",
  access = "https://api.instagram.com/oauth/access_token")
myapp <- oauth_app(app_name, client_id, client_secret)

ig_oauth <- oauth2.0_token(instagram, myapp,scope="basic",  type = "application/x-www-form-urlencoded",cache=FALSE)

输出:

Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.

输入:

tmp <- strsplit(toString(names(ig_oauth$credentials)), '"')
token <- tmp[[1]][4]
username <- "therock"
user_info <- fromJSON(getURL(paste('https://api.instagram.com/v1/users/search?q=',username,'&access_token=',token,sep="")),unexpected.escape = "keep")
received_profile <- user_info$data[[1]]

输出/错误:

Error in user_info$data[[1]] : subscript out of bounds

如果我将上述代码中的查询直接运行到我的浏览器中,

https://api.instagram.com/v1/users/search?q=therock&access_token=511932783.a364240.562161d569354bf78b043c98cf938235

我收到以下内容:

{"meta": {"code": 200}, "data": []}

0 个答案:

没有答案