使用 Curl 下拉呼叫日志数据

Using Curl to pull down Call Log Data

我想使用 shell 脚本和 curl 从 RingCentral 提取通话数据。然后我将把它放入 ELK 中以使用 Kibana 构建仪表板。但是,我不知道我在用 API 做什么。有没有人可以让我开始或提供一些示例代码来执行此操作?

我目前正在努力使用 curl 进行身份验证以获取令牌。目前,我不断收到不受支持的赠款类型。我在 Sandbox 和 "Server Only No UI".

中设置了应用程序

我使用 bash shell.

从 Centos 7 盒子中获得 运行 这个

这里是试过的代码:

curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token"; \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=<extension>&grant_type=password"

我将用户名和密码留空,因为我不确定那是什么。

输出结果如下:

{
  "error" : "invalid_request",
  "error_description" : "Unsupported grant type",
  "errors" : [ {
    "errorCode" : "OAU-250",
    "message" : "Unsupported grant type"
  } ]
}./rctest1.sh: line 2: -H: command not found

我已经能够重现您的错误,并且可以通过在您的命令中删除 URL 之后的分号 (;) 来解决它。

说明

分号创建两个单独的 CLI 命令而不是一个,因此在您的调用中,您有两个请求。

- 您的要求 1

$ curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token"

- 您的要求 2

$ -H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=&grant_type=password"

- 您的回复 1

{
  "error" : "invalid_request",
  "error_description" : "Unsupported grant type",
  "errors" : [ {
    "errorCode" : "OAU-250",
    "message" : "Unsupported grant type"
  } ]
}

- 您的回复 2

./rctest1.sh: line 2: -H: command not found

- 测试命令

这是一个简单的测试,显示 OS 试图处理两个命令:

$ hello;world
-bash: hello: command not found
-bash: world: command not found

解决方案

- 工作要求

这是一个没有分号的工作请求:

$ curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token" \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "my client id:my client secret" \
-d "username=username&password=password&extension=&grant_type=password"

- 工作反应

这是工作响应:

{
  "access_token" : "myAccessToken",
  "token_type" : "bearer",
  "expires_in" : 3600,
  "refresh_token" : "myRefreshToken",
  "refresh_token_expires_in" : 604800,
  "scope" : "Meetings VoipCalling Glip SubscriptionWebhook Faxes Contacts RingOut SMS",
  "owner_id" : "11111111",
  "endpoint_id" : "22222222"
}