【问题标题】:Has anyone tried the Piwik PRO api in R?有没有人在 R 中尝试过 Piwik PRO api?
【发布时间】:2021-03-13 10:28:38
【问题描述】:

我想在 R 中使用 Piwik PRO api,但找不到代码示例。

有谁知道如何将其格式化为 R 代码? (或者可以帮我指出一个可以帮助我自己做这件事的来源?)

    curl -X POST 'https://<domain>/auth/token' -H "Content-Type: application/json" --data '{
"grant_type": "client_credentials",
"client_id": "your_generated_client_id",
"client_secret": "your_generated_client_secret"
 }'

【问题讨论】:

    标签: r api httr rcurl matomo


    【解决方案1】:

    我建议使用httr package。 身份验证代码应如下所示:

    library(httr) 
    
    url <- "" 
    
    payload <- "{ \"grant_type\": \"client_credentials\", \"client_id\": \"\", \"client_secret\": \"\" }" 
    
    encode <- "json" 
    
    response <- VERB("POST", url, body = payload, add_headers(Content_Type = 'application/json'), content_type("application/json"), encode = encode) 
    
    content(response, "text")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-21
      • 2013-02-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-10
      • 2013-07-07
      • 2018-05-08
      • 1970-01-01
      相关资源
      最近更新 更多