我想连接到instagram API并通过R获取数据。最后我遇到subscript out of bounds
错误。请帮我解决一下。感谢
app_name<-"HamidTT"
client_id<-"xxx"
client_secret<-"xxx"
scope="public_content"
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="public_content", 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<-"hrouhani"
user_info <- fromJSON(getURL(paste('https://api.instagram.com/v1/users/search?q=',username,'&access_token=',token,sep="")),unexpected.escape = "keep")
user_info
# $meta
# $meta$code
# [1] 200
# $data
# list()
received_profile <- user_info$data[[1]]
# **Error in user_info$data[[1]] : subscript out of bounds**