wlmaroc / ovh-sms-bundle
OVH SDK 集成
dev-master
2017-06-05 13:20 UTC
Requires
- henrikbjorn/phpspec-code-coverage: ~1.0
- ovh/ovh: ~1.1
- symfony/config: ~2.3
- symfony/dependency-injection: ~2.3
- symfony/http-kernel: ~2.3
Requires (Dev)
- phpspec/phpspec: ~2.1
- satooshi/php-coveralls: ~0.6
This package is not auto-updated.
Last update: 2024-09-23 17:22:20 UTC
README
此包将OVH的官方PHP SDK集成到Symfony框架中。
安装
使用 Composer 安装包
composer require wlmaroc/ovh-sms-bundle
然后,更新您的 app/config/AppKernel.php
文件
public function registerBundles() { $bundles = array( // ... new Wlmaroc\OvhSmsBundle\WlmarocOvhSmsBundle(), // ... ); return $bundles; }
在 app/config/config.yml
中配置包
wlmaroc_ovh: endpoint_name: "%ovh_endpoint_name%" application_key: "%ovh_application_key%" application_secret: "%ovh_application_secret%" consumer_key: "%ovh_consumer_key%"
最后,更新您的 app/config/parameters.yml
文件以存储您的OVH API凭证
parameters: # ... ovh_endpoint_name: "ovh-eu" ovh_application_key: "MyOvhApplicationKey" ovh_application_secret: "MyOvhApplicationSecret" ovh_consumer_key: "MyOvhConsumerKey"
使用方法
该包会自动在依赖注入容器中注册一个 ovh
服务。该服务是 \Ovh\Api
的一个实例。
控制器中的示例使用
// ... public function smsAction() { // Send a SMS $this ->get('ovh') ->post( sprintf('/sms/%s/users/%s/jobs', 'my-service-name', 'my-login'), [ 'message' => 'Si tu veux me parler, envoie-moi un... fax !', 'receivers' => '+33612345678', 'sender' => 'my-login', ] ) ; // ... } // ... }
致谢
由 [Web Logiciel Maroc] (http://wlmaroc.com) 创建。