我正在关注几年前Stack Overflow 线程上提供的代码,但是当我运行“fromJSON”命令时出现错误,“代码 86,此方法需要 GET 或 HEAD”。我正在尝试从公共 Twitter 列表(所有 NHL 球员)中获取用户名列表。
这是代码
# load packages
library("twitteR")
library("rjson")
library("httr")
consumer_key <- "XXX"
consumer_secret <- "XXX"
access_token <- "XXX"
access_secret <- "XXX"
options(httr_oauth_cache=T)
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
twlist <- "nhl-players"
twowner <- "NHL"
api.url <- paste0("https://api.twitter.com/1.1/lists/members.json?slug=",
twlist, "&owner_screen_name=", twowner, "&count=500")
response <- POST(api.url, config(token=twitteR:::get_oauth_sig()))
fromJSON(content(response, as = "text", encoding = "UTF-8"))