【问题标题】:Using R to access Pheedloop API使用 R 访问 Phedloop API
【发布时间】:2022-10-07 05:49:39
【问题描述】:

我的组织使用 Pheedloop,我正在尝试构建一个动态解决方案来访问其数据。

那么,如何使用 R 访问 Pheedloop API?具体来说,我如何准确地将我的 API 凭据提交给 Pheedloop 并下载数据。我还需要最终数据采用数据框格式。

    标签: r json rcurl


    【解决方案1】:

    我的组织使用 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      • 2021-07-26
      • 1970-01-01
      • 2019-05-17
      • 2021-08-12
      相关资源
      最近更新 更多