1

我正在使用 RingCentral 的 API,试图提取我们帐户中所有用户的存在状态(我们有 30 个)。我已经检查了 RingCentral Admin 端,并确保所有手机都启用了显示状态。我有以下代码可以正常工作并进入存在状态。但是,它只会拉入一个扩展。有没有人熟悉这个 API 以及如何查询所有扩展?下面的代码:(就像我说的那样,这工作得很好,只需拉入一个扩展程序(我登录的那个)。

require_once(__DIR__ . '/_bootstrap.php');
use RingCentral\SDK\SDK;

// Create SDK instance
$credentials = require(__DIR__ . '/_credentials.php');
$rcsdk = new SDK($credentials['clientId'], $credentials['clientSecret'], $credentials['server'], 'Demo', '1.0.0');
$platform = $rcsdk->platform();

// Authorize
$platform->login($credentials['username'], $credentials['extension'], $credentials['password']);

// Load extensions  //
$extensions = $platform->get('/account/~/extension', array('perPage' => 10))->json()->records;

// show user count here, only showing a count of 1
print 'Users loaded ' . count($extensions) . PHP_EOL;

$presences = $platform->get('/account/~/extension/' . $extensions[0]->id . ',' . $extensions[0]->id . '/presence')
                  ->multipart();

$presences00 = $platform->get('/account/~/extension/~')
                  ->json();

echo "<textarea style='width:100%;height:500px;'>";
                  print_r($presences00);
                  echo "</textarea>";

print 'Presence loaded ' .
  $extensions[0]->name . ' - ' . $presences[0]->json()->presenceStatus . ', ' .
  $extensions[0]->name . ' - ' . $presences[1]->json()->presenceStatus . PHP_EOL;

这是实际 PHP 文件的工作链接:http: //silkrut.com/william2/vendor/ringcentral/ringcentral-php/demo/ext.php

Ring Central 的文档: https ://devcommunity.ringcentral.com/ringcentraldev/topics/where-could-i-lookup-my-accountid-and-extensionid-st8045nl19xkj 他们在底部声明的地方“ Tyler Long,官方代表方式向 /restapi/v1.0/account/~/extension 发送 GET 请求以获取您帐户中的扩展程序列表。”

如果有人可以提供帮助或知道我在这里可能出错的地方,我将不胜感激!感谢您的宝贵时间!

4

1 回答 1

1

要获得所有分机的状态,您只需使用管理员分机登录,然后调用公司状态端点。

$presences = $platform->get('/account/~/presence');

如果你想获得详细的状态,记得添加标志

$presences = $platform->get('/account/~/presence?detailedTelephonyState=true');
于 2018-05-22T18:19:08.783 回答