bankiru/sms-online

此包已被放弃,不再维护。未建议替代包。

适用于sms-online.ru短信网关的绑定

1.0 2017-01-10 09:56 UTC

This package is not auto-updated.

Last update: 2022-11-07 15:54:11 UTC


README

sms-online.ru短信网关的PHP绑定

安装

composer require bankiru/sms-online

使用方法

独立使用

<?php

use Bankiru\Sms\SmsOnline\SmsOnline;
use Bankiru\Sms\SmsOnline\SmsOnlineTransport;
use ScayTrase\SmsDeliveryBundle\Service\ShortMessageInterface;

class MySms implements  ShortMessageInterface {
    /* ... */
}

$transport = new SmsOnlineTransport(
    new SmsOnline(new \GuzzleHttp\Client(), 'user', 'pass', 'https://service.qtelecom.ru/public/http/'),
    'friendly_man',
    new \Psr\Log\NullLogger(),
    '_transaction_prefix'
);
$transport->send(new MySms('1234567890', 'message body'));

Symfony框架使用

将包注册到内核

class AppKernel extends Kernel {
    public function registerBundles() {
        return [
            //...
            new \ScayTrase\SmsDeliveryBundle\SmsDeliveryBundle();
            new \Bankiru\Sms\QtSms\QtSmsBundle(),
            //...
        ];
    }
}

配置发送者

sms_delivery:
  transport: sms_online.transport

sms_online:
    login: user
    password: pass
    url: https://bulk.sms-online.com/
    sender: friendly_man
    transaction_prefix: _transaction_prefx_

发送短信

class MyController extends Controller {
    public function sendAction() {
        $this->get('sms_delivery.sender')->spoolMessage(new MySms('1234567890', 'message body'));
    }
}