akibatech / laravel-free-mobile-sms
为 Laravel 5 集成 Free Mobile 发送 SMS
1.0.3
2017-01-24 17:29 UTC
Requires
- php: >=5.5.9
- illuminate/support: >=5.1
This package is not auto-updated.
Last update: 2024-09-17 10:06:10 UTC
README
此包允许您轻松地从 Laravel 5 应用程序发送 SMS 通知到您的 Free Mobile 电话。
如果您是 Free Mobile 用户,这个选项是免费的!不要错过这个机会:)
目录
安装
使用 Composer 安装此包
composer require akibatech/laravel-free-mobile-sms
将 ServiceProvider 添加到 config/app.php
Akibatech\FreeMobileSms\ServiceProvider::class,
如果您想使用 facade,请在此配置文件中包含它
'Freemobile' => Akibatech\FreeMobileSms\Facade::class,
然后,通过以下命令发布配置文件 laravel-free-mobile-sms
php artisan vendor:publish --provider="Akibatech\FreeMobileSms\ServiceProvider"
使用
在您的电话上发送短信
FreeMobileSms::send('Elle est où la poulette !?');
通过传递实例(DI)发送短信
public function myControllerAction(Akibatech\FreeMobileSms\FreeMobileSms $client) { $sms->send('Pas changer assiette pour fromage !'); }
或者,从容器中获取实例
public function myControllerAction() { app('freemobile')->send("C'est pas faux."); }
Laravel 通知
如果您使用的是 Laravel 5.3,则可以将此包用作 Laravel 通知的驱动程序。
示例
namespace App\Notifications; use Akibatech\FreeMobileSms\Notifications\FreeMobileChannel; use Akibatech\FreeMobileSms\Notifications\FreeMobileMessage; use Illuminate\Notifications\Notification; class ExampleNotification extends Notification { /** * Notification via FreeMobileChannel. */ public function via($notifiable) { return [FreeMobileChannel::class]; } /** * Your notification must implements "toFreeMobile()" */ public function toFreeMobile($notifiable) { return (new FreeMobileMessage("C'est marrant les petits bouts de fromage par terre. C'est ça que vous appelez une fondue ?")); } }
就这样,现在您可以使用您的 Free Mobile 电话免费接收 SMS 通知了:)
获取您的凭据
非常简单,请访问您的 Free Mobile 订户空间,然后转到“管理我的账户”部分下的“我的选项”子菜单。
您将在下面的截图中找到您的凭据。
一旦您手头有了凭据,请将它们添加到文件 config/laravel-free-mobile-sms.php 中。
您也可以在未版本化的文件 .env 中进行配置。
- FREE_USER > 您的客户标识(8 位数字)
- FREE_PASS > 您的 SMS 标识密钥
支持
不要犹豫,使用问题跟踪来反馈您的意见。
作者
许可证
MIT