fomvasss/epochta-sms

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

Laravel ~5.3 发送短信的包

v1.0.2 2017-03-27 09:51 UTC

This package is auto-updated.

Last update: 2020-04-05 09:03:19 UTC


README

Laravel ~5.3 发送短信的包(使用服务 https://www.epochta.ru

安装

composer require "fomvasss/epochta-sms"

在 config/app.php 中注册服务提供者和别名

  Fomvasss\Epochta\EpochtaServiceProvider::class,
  ...
  'Epochta' => Fomvasss\Epochta\Services\Epochta::class,

然后使用以下命令发布资源

php artisan vendor:publish

这将添加 config/epchta_sms.php 文件

配置

编辑文件 config/epchta_sms.php,设置

  • private_key
  • public_key
  • test_mode
  • sms_lifetime
  • currency

使用

##使用 Epochta 门面

use Fomvasss\Epochta\Services\Facade\Epochta;

现在,你可以使用以下命令

Epochta::sendSms($sender, $text, $phone) //return ID SMS
Epochta::getUserBalance()   //return float
Epochta::getSmsStatus($idSms);  //return string status SMS

Function getSmsStatus() 返回以下状态

  • 服务器错误
  • 在发送队列中
  • 已发送
  • 已送达
  • 未送达
  • 无效号码
  • 发送到垃圾邮件

##使用对象 APISMS, Addressbook 和 Account(原始 API)

use Fomvasss\Epochta\Libraries\APISMS;
use Fomvasss\Epochta\Libraries\Account;
use Fomvasss\Epochta\Libraries\Addressbook;
use Fomvasss\Epochta\Libraries\Exceptions;
$sms=new APISMS();
$addressbook=new Addressbook($Gateway);
$account=new Account($Gateway);
$account=new Exceptions($Gateway);

发送的短信示例

$res = $sms->sendSMS('SenderName', 'your sms text :)', '+380969416666', null, 0);
$res['result']['id']; // ID SMS

其他方法和 API 请参阅此文档