pacovu / engagevoice-sdk-wrapper
PHP版本的RingCentral Engage Voice SDK包装器
dev-master
2023-07-17 21:18 UTC
Requires
- php: >=7.1
This package is not auto-updated.
Last update: 2024-09-20 20:16:12 UTC
README
概述
PHP版本的Engage Voice SDK包装器是一个实用类,它可以帮助您轻松地将您的PHP项目与RingCentral Engage Voice服务集成。SDK允许您使用两种不同的模式对用户进行身份验证,即ENGAGE模式和LEGACY模式。在ENGAGE模式下,您必须...
安装Engage Voice SDK包装器
$ composer require pacovu/engagevoice-sdk-wrapper:dev-master
API参考
构造函数
RestClient($clientId, $clientSecret)
描述
- 创建并初始化一个EngageVoice SDK包装器对象。如果提供了
$clientId
和$clientSecret
参数,SDK将被设置为ENGAGE模式,您可以使用RingCentral MVP用户登录凭据进行登录。如果省略了$clientId
和$clientSecret
参数,SDK将被设置为LEGACY模式,您可以使用用户名和密码登录旧服务器。
参数
- $clientId: 设置RingCentral应用的
clientId
以使用RingCentral MVP用户凭据进行登录。 - $clientSecret: 设置RingCentral应用的
clientSecret
以使用RingCentral MVP用户凭据进行登录。
ENGAGE模式示例代码
require('vendor/autoload.php');
$ev = new EngageVoiceSDKWrapper\RestClient(RINGCENTRAL_CLIENT_ID, RINGCENTRAL_CLIENT_SECRET)
LEGACY模式示例代码
require('vendor/autoload.php');
$ev = new EngageVoiceSDKWrapper\RestClient()
登录函数 login($options, function ($response) )
描述
- 使用用户的凭据进行登录。如果SDK模式是"Engage",则用户名和密码必须是RingCentral Office用户的有效用户名和密码。
参数
- $options: 登录凭据的数组。对于"Engage"模式,设置
jwt
令牌。对于"Legacy"模式,设置username
和password
。
响应
示例代码
// Login with RingCentral Office user credentials.
require('vendor/autoload.php');
$ev = new EngageVoiceSDKWrapper\RestClient(RC_CLIENT_ID, RC_CLIENT_SECRET);
RC_JWT= "personal-jwt-token";
$ev->login([ 'jwt' => RC_JWT ], function($response){
// call the get or post function
...
});
// Login with Legacy user credentials
$ev = new EngageVoiceSDKWrapper\RestClient();
USERNAME= "your-username";
PASSWORD= "your-password";
$ev->login([ 'username' => USERNAME, 'password' => PASSWORD ]) {
// call get or post function
...
});
获取函数
get($endpoint, $params, "callback");
描述
- 向Engage Voice服务器发送HTTP GET请求。
参数
- $endpoint: Engage Voice API端点。
- $params: 一个包含键值对参数的JSON对象,这些参数将被发送到Engage Voice API,其中键是API的查询参数。
- "callback": 回调函数的名称。如果指定,响应将通过回调函数返回。
响应: JSON对象中的API响应
示例代码
# Read account info.
$endpoint = "admin/accounts";
try{
$resp = $ev->get($endpoint);
print ($resp);
}catch (Exception $e) {
print $e->getMessage();
}
POST函数
post($endpoint, $params, "callback");
描述
- 向Engage Voice服务器发送HTTP POST请求。
参数
- $endpoint: Engage Voice API
- $params: 一个包含键值对参数的JSON对象,这些参数将被发送到Engage Voice API,其中键是API的主体参数。
- "callback": 回调函数的名称。如果指定,响应将通过回调函数返回。
响应: JSON对象中的API响应
示例代码
# Search for campaign leads.
$endpoint = "admin/accounts/~/campaignLeads/leadSearch";
$params = array ( 'firstName' => "Larry" );
try{
$resp = $ev->post($endpoint, $params);
print ($resp);
}catch (Exception $e) {
print $e->getMessage();
}
许可协议
在MIT许可证下许可。