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

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

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

gateway/sms

Composer 安装命令:

composer require gateway/sms

包简介

sms gateway

README 文档

README

Latest Version on Packagist Total Downloads

This is a Laravel Package for SMS Gateway Integration. Now Sending SMS is easy.

List of supported gateways:

  • log : for test
  • Farazsms
  • Others are under way.

package: Install

Via Composer

$ composer require gateway/sms

In the config file you can set the default driver to use for all your SMS. But you can also change the driver at runtime.

Choose what gateway you would like to use for your application. Then make that as default driver so that you don't have to specify that everywhere. But, you can also use multiple gateways in a project.

'default' => 'log',

Then fill the credentials for that gateway in the drivers array.

// Eg. for farazsms.
'drivers' => [
    'farazsms' => [
        'url'     => env('FARAZSMS_URL', 'http://rest.ippanel.com'),
        'from'    => env('FARAZSMS_FROM'),
        'api_key' => env('FARAZSMS_API_KEY'),
    ],
    ...
]

log Configuration:

log is added by default. You just have to change the creadentials in the textlocal driver section.

Kavenegar Configuration:

In case you want to use Kavenegar. Then you have to pull a composer library first.

composer require kavenegar/php

Usage

In your code just use it like this.

# On the top of the file.
use Gateway\Sms\Facades\Sms;

...

# In your Controller.
Sms::content("this message")->to(['Number 1', 'Number 2'])->send();

😍 Channel Usage

First you have to create your notification using php artisan make:notification command. then sms can be used as channel like the below:

namespace App\Notifications;

use Gateway\Sms\Channels\SmsMessage;use Illuminate\Bus\Queueable;
use Gateway\Sms\Channels\SmsChannel;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;

class VerificationNotification extends Notification
{
    use Queueable;

    /**
     * Get the notification channels.
     *
     * @param  mixed  $notifiable
     * @return array|string
     */
    public function via($notifiable)
    {
        return ['sms'];
    }

    /**
     * Get the repicients and body of the notification.
     *
     * @param  mixed  $notifiable
     * @return Builder
     */
    public function toSms($notifiable)
    {
        # for send message.
        return (new SmsMessage())
            ->via('gateway') # via() is Optional
            ->content('this message')
            ->to('some number')
            ->send();
        # for send by pattern.
        return (new SmsMessage())
            ->via('gateway') # via() is Optional
            ->patternCode('mfgfdm')
            ->patternData(['code' => '45215'])
            ->to('some number')
            ->send();
    }
}

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-11-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固