yoqut/sms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yoqut/sms

最新稳定版本:v2.2

Composer 安装命令:

composer require yoqut/sms

包简介

An SMS component for PHP applications.

README 文档

README

An SMS component for PHP applications.

Installation

php composer.phar require yoqut/sms

Usage

// Imports
use Yoqut\Component\Sms\Factory\SmsFactory;
use Yoqut\Component\Sms\Factory\GatewayFactory;
use Yoqut\Component\Sms\Gateway\Matcher;
use Yoqut\Component\Sms\Sender\Sender;

// Create a new SMS
$sms = SmsFactory::create();
$sms->setSender('Sender');
$sms->setRecipient('5550100');
$sms->setMessage('Message');

// Create a new gateway
// Provide host, port, interface version, username, password, service numbers (optional),
// prefix codes (optional) and configurations (optional)
$gateway = GatewayFactory::create(
    'localhost',
    2775,
    0x34
    'username',
    'password',
    array(
        '5555', // Production
        '4444' // Development
    ),
    array('555')
);

// Array of gateways
$gateways = array($gateway);

// Create a new gateway matcher
$matcher = new Matcher($gateways);
$matchedGateway = $matcher->match($sms);

// Print the matched gateway
echo '<pre>';
print_r($matchedGateway);
echo '</pre>';

if ($matchedGateway) {
    // Use one of the gateway service numbers as a sender if needed
    $serviceNumbers = $gateway->getServiceNumbers();
    $sms->setSender($serviceNumbers[0]);

    // Send an SMS to the matched gateway
    $sender = new Sender();
    $messageId = $sender->send($sms, $matchedGateway);
    echo $messageId;
}

Tests

bin/phpspec run

License

MIT License

Authors

The component was created by Sukhrob Khakimov. See the list of contributors.

统计信息

  • 总下载量: 132
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 1
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-18