coxy121 / ringcentral-laravel
此包已被弃用且不再维护。未建议替代包。
Laravel RingCentral SDK for PHP 包
v0.4.0
2020-10-01 15:03 UTC
Requires
- php: >=7.1.3
- illuminate/support: ~5.8.0|^6.0|^7.0|^8.0
- ringcentral/ringcentral-php: ^2.1
Requires (Dev)
- orchestra/testbench: ^4.0|^5.0
- phpunit/phpunit: ^8.3|^9.0
- vlucas/phpdotenv: ^3.6
This package is auto-updated.
Last update: 2023-03-17 01:33:18 UTC
README
已废弃,推荐使用 coxlr/laravel-ringcentral
简介
这是一个简单的 Laravel 服务提供者,提供了对 RingCentral SDK for PHP 的访问。
安装
使用 Composer 安装 PHP 客户端库
composer require coxy121/ringcentral-laravel
或者,将以下两行添加到你的 composer require 部分
{ "require": { "coxy121/ringcentral-laravel": "^1.0" } }
Laravel 5.5+
如果你使用的是 Laravel 5.5 或更高版本,则该包将自动注册 RingCentral
提供者和外观。
Laravel 5.4 及以下
将 RingCentral\Laravel\RingCentralServiceProvider
添加到你的 config/app.php
文件中的 providers
数组中
'providers' => [ // Other service providers... RingCentral\Laravel\RingCentralServiceProvider::class, ],
如果你想要使用外观接口,可以在需要时使用外观类
use RingCentral\Laravel\Facade\RingCentral;
或者在你的 config/app.php
中添加别名
'aliases' => [ ... 'RingCentral' => RingCentral\Laravel\Facade\RingCentral::class, ],
配置
你可以使用 artisan vendor:publish
命令将配置文件复制到你的应用的配置目录
php artisan vendor:publish
然后更新 config/ringcentral.php
文件以包含你的凭证。或者,你也可以更新你的 .env
文件,如下所示
RINGCENTRAL_CLIENT_ID=my_client_id
RINGCENTRAL_CLIENT_SECRET=my_client_secret
RINGCENTRAL_SERVER_URL=my_server_url
RINGCENTRAL_USERNAME=my_username
RINGCENTRAL_OPERATOR_EXTENSION=my_operator_extension
RINGCENTRAL_OPERATOR_PASSWORD=my_operator_password
#If admin details are a different extension to the operator
RINGCENTRAL_ADMIN_EXTENSION=my_admin_extension
RINGCENTRAL_ADMIN_PASSWORD=my_admin_password
用法
要使用 RingCentral 客户端库,你可以使用外观,或者从服务容器中请求实例。
发送短信消息(需要在扩展中登录为公司操作员)
RingCentral::sendMessage([ 'to' => '13107960080', 'text' => 'Using the facade to send a message.' ]);
或者
$ringcentral = app('ringcentral'); $ringcentral->sendMessage([ 'to' => '13107960080', 'text' => 'Using the instance to send a message.' ]);
属性
名称 | 必需 | 类型 | 默认 | 描述 |
---|---|---|---|---|
to | true | String | 发送短信的目标号码,必须包含国家代码 | |
text | true | String | 要发送的消息文本 |
检索扩展(需要管理员权限)
RingCentral::getExtensions();
或者
$ringcentral = app('ringcentral'); $ringcentral->getExtensions();
获取操作员发送和接收的消息
RingCentral::getOperatorMessages();
或者
$ringcentral = app('ringcentral'); $ringcentral->getOperatorMessages();
默认的起始日期是前 24 小时,要指定搜索的起始日期,请传递所需日期作为参数。
RingCentral::getOperatorMessages((new \DateTime())->modify('-1 hours'));
参数
名称 | 必需 | 类型 | 默认 | 描述 |
---|---|---|---|---|
fromDate | false | Object | 搜索起始的日期和时间必须是一个 PHP 日期对象 | |
toDate | false | Object | 结束搜索的日期和时间必须是一个PHP日期对象 | |
perPage | false | 整型 | 100 | 每页返回的记录数 |
获取指定扩展发送和接收的消息(需要管理员权限)
RingCentral::getMessagesForExtensionId(12345678);
或者
$ringcentral = app('ringcentral'); $ringcentral->getMessagesForExtensionId(12345678);
默认的起始日期是前24小时,要指定搜索的起始日期,请传递所需的日期参数。
RingCentral::getMessagesForExtensionId(12345678, (new \DateTime())->modify('-1 hours'));
参数
名称 | 必需 | 类型 | 默认 | 描述 |
---|---|---|---|---|
extensionId | true | String | 要检索消息的RingCentral扩展ID | |
fromDate | false | Object | 搜索起始的日期和时间必须是一个 PHP 日期对象 | |
toDate | false | Object | 结束搜索的日期和时间必须是一个PHP日期对象 | |
perPage | false | 整型 | 100 | 每页返回的记录数 |
获取消息附件(需要管理员权限)
RingCentral::getMessageAttachmentById(12345678, 910111213, 45678910);
或者
$ringcentral = app('ringcentral'); $ringcentral->getMessageAttachmentById(12345678, 910111213, 45678910);
参数
名称 | 必需 | 类型 | 默认 | 描述 |
---|---|---|---|---|
extensionId | true | String | messageId | |
消息ID,附件所属的消息ID | true | String | attachmentId | |
附件ID | true | String | 附件的ID |
有关使用RingCentral客户端库的更多信息,请参阅官方客户端库存储库。