open-ecommerce / yii2-telerivet
此组件是 Telerivet PHP 模块的 YII2 包装器
v1.1
2017-03-19 15:05 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-28 22:31:25 UTC
README
此组件是 Telerivet PHP SDK 的 YII2 包装器。
安装
安装此扩展的首选方式是通过 composer。
运行以下命令:
php composer.phar require --prefer-dist open-ecommerce/yii2-telerivet "dev-master"
或者如果您已经全局安装了 composer
composer require --prefer-dist open-ecommerce/yii2-telerivet "dev-master"
或者在您的 composer.json
文件的 require 部分添加以下内容:
"open-ecommerce/yii2-telerivet": "dev-master"
根据您在 composer.json 中定义的最小 composer 要求,您可能需要添加以下仓库:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/open-ecommerce/yii2-telerivet"
},
...
用法
扩展安装后,只需在您的配置中添加以下内容即可使用它:
'components' => array( ... 'Yii2Telerivet' => array( 'class' => 'openecommerce\yiiTelerivet\YiiTelerivet', 'account_sid' => getenv('Telerivet_ACCOUNT_SID'), 'auth_key' => getenv('Telerivet_AUTH_KEY'), ), ... );
配置组件后,您可以按照以下方式使用它,例如:
$TelerivetService = Yii::$app->Yii2Telerivet->initTelerivet(); try { $message = $TelerivetService->account->messages->create( "+12345678901", // To a number that you want to send sms array( "from" => "+12345678901", // From a number that you are sending "body" => "Hello from my Yii2 Application!", )); } catch (\Telerivet\Exceptions\RestException $e) { echo $e->getMessage(); }
有关更多 SDK 函数和用法文档,请自由访问官方 Telerivet PHP SDK 文档部分 这里。
资源
如果您有任何问题,请随时提问。