mocean / client7
Mocean API 的 PHP 客户端。
2.1.2
2021-08-04 10:28 UTC
Requires
- php: ^7.3 | ^8.0
- php-http/guzzle7-adapter: ^0.1
Requires (Dev)
- php-http/mock-client: *
- phpspec/prophecy-phpunit: *
- phpunit/phpunit: ^8.0 | ^9.0
This package is auto-updated.
Last update: 2024-09-18 11:44:44 UTC
README
此库需要 PHP 版本至少为 5.5
这是 Mocean API 的 PHP 客户端库。要使用此库,您需要一个 Mocean 账户。在 moceanapi.com 上免费注册。
安装
要使用客户端库,您需要创建一个 Mocean 账户。
使用 Composer 安装 PHP 客户端库。
composer require mocean/client7
使用方法
如果您正在使用 composer,请确保将自动加载器包含在您的项目引导文件中
require_once "vendor/autoload.php";
使用您的 API 密钥和密钥创建客户端
use Mocean\Client; use Mocean\Client\Credentials\Basic; $mocean = new Client(new Basic('API_KEY_HERE','API_SECRET_HERE'));
示例
要使用 Mocean 的 SMS API 发送短信,请调用 $mocean->message()->send();
方法。
可以直接调用 API,使用简单的参数数组,键与 API 的参数匹配。
$res = $mocean->message()->send([ 'mocean-to' => '60123456789', 'mocean-from' => 'MOCEAN', 'mocean-text' => 'Hello World' ]); echo $res;
响应
为了方便,可以使用 PHP 的 object
或 array
风格访问 API 响应数据
echo $res; //show full response string echo $res['status']; //show response status, '0' in this case echo $res->status; //same as above
文档
请访问 MoceanApi 文档 了解更多用法
许可证
此库在 MIT 许可证下发布