【发布时间】:2022-10-07 05:49:39
【问题描述】:
我的组织使用 Pheedloop,我正在尝试构建一个动态解决方案来访问其数据。
那么,如何使用 R 访问 Pheedloop API?具体来说,我如何准确地将我的 API 凭据提交给 Pheedloop 并下载数据。我还需要最终数据采用数据框格式。
我的组织使用 Pheedloop,我正在尝试构建一个动态解决方案来访问其数据。
那么,如何使用 R 访问 Pheedloop API?具体来说,我如何准确地将我的 API 凭据提交给 Pheedloop 并下载数据。我还需要最终数据采用数据框格式。
我的组织使用 Pheedloop 组织会议,我需要总结相关事件、注册人员等。如果您有帐户和必要的凭据,以下是访问 Pheedloop 数据的方法:
orgcode<-'yourcode'
myapikey<-'yourapikey'
mysecret<-'yourapisecret'
library(RCurl)
library(jsonlite)
# AUTHENTICATION
authen<-paste0("https://api.pheedloop.com/api/v3/organization/",orgcode,"/validateauth/") # create a link with parameters
RCurl::getURL(
authen,
httpheader = c('X-API-KEY' = myapikey, 'X-API-SECRET' = mysecret), # include key and secret in the header like this
verbose = TRUE)
# LIST EVENTS
events<-paste0("https://api.pheedloop.com/api/v3/organization/",orgcode, " events/")
# the result will be a JSON file
cscEvents<-getURL(
events,
httpheader = c('X-API-KEY' = myapikey, 'X-API-SECRET' = mysecret),
verbose = FALSE)
cscEvents<-fromJSON(cscEvents ); # using jsonlite package to parse json format
cscEventsResults<-cscEvents$results # accessing the results table
table(cscEventsResults$event_name) # examine
【讨论】: