ogizanagi / ovh-sms-bundle
v0.1
2014-10-14 12:09 UTC
Requires
- php: >=5.3.2
- symfony/framework-bundle: ~2.3
- symfony/options-resolver: ~2.3
This package is not auto-updated.
Last update: 2015-08-02 13:36:14 UTC
README
描述
通过 ovh SOAP API 发送短信。
安装
将以下依赖项添加到您的 composer.json 文件中
{ "require": { "_other_packages": "...", "ogizanagi/ovh-sms-bundle": "dev-master" } }
为此包运行 composer update,并将以下行添加到您的 AppKernel.php
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Ogi\OvhSmsBundle\OgiOvhSmsBundle(), ); }
配置
#config.yml---------------------- #Sms OVH Soap API configuration: ogi_ovh_sms: soap_host: ~ login: nic: yurnic-ovh pass: p@ssw0rd handle: fr sms_account: account: sms-yurnic-1 from: YURNAME
用法
配置完成后,即可使用该服务
$smsSenderFactory = $this->container->get('ogi.ovh_sms.factory.sms_sender'); $smsSender = $smsSenderFactory->getSmsSender(); $failed = []; $smsConfig = SMSConfiguration::create(array( 'no_stop' => true, 'coding' => 2, //unicode )); $phoneNumber = "+33606060606"; $sms = new SMS($phoneNumber, $message); $result = $smsSender->sendSms($sms, $smsConfig, $failed);
有关短信配置的更多信息,请参阅 SMSConfiguration 选项。
注意:`Ogi\OvhSmsBundle\Services\SmsSender
` 类仅是对 `Ogi\OvhSmsBundle\Services\APIClient
` 类的包装,用于处理 `Ogi\OvhSmsBundle\Model\SMS
` 和 `Ogi\OvhSmsBundle\Configuration\SMSConfiguration
` 类,并且也可以直接从 `ogi.ovh_sms.factory.api_client` 服务工厂中使用。
SMSConfiguration 选项
validity
:消息被丢弃前的最大时间(分钟),默认为 48 小时sms_class
:flash(0),手机显示(1),SIM(2),工具箱(3)(可用常量)deferred
:发送消息前等待的时间(分钟),默认为 0priority
:消息的优先级(0 到 3),默认为 3coding
:短信编码:1 为 7 位,2 为 unicode,默认为 1tag
:可选标签no_stop
:不在消息中显示 STOP 条款。仅适用于非广告信息。
SMSConfiguration 类内部使用 `symfony/options-resolver
` 组件,并可以轻松扩展以处理常用的 SMS 类型,根据需要覆盖 `setDefaultOptions`。
改进
可以进行以下改进
- 改进错误处理。
- 其他建议的改进。