定制 shiroamada/green-api-laravel-notification 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

shiroamada/green-api-laravel-notification

最新稳定版本:v11.2.0

Composer 安装命令:

composer require shiroamada/green-api-laravel-notification

包简介

Green API Notifications channel for Laravel 11 and Above

README 文档

README

Latest Version on Packagist Software License Build Status StyleCI Quality Score Code Coverage Total Downloads

This package makes it easy to send notifications using https://green-api.com/en/ with Laravel 11+.

Code Reference from laravel-notification-channels/smsc-ru

Contents

Installation

You can install the package via composer:

composer require shiroamada/green-api-laravel-notification

Then you must install the service provider:

// config/app.php
'providers' => [
    ...
    NotificationChannels\GreenApi\GreenApiServiceProvider::class,
],

Setting up the Green API service

Add your green api instanceId and token to your config/services.php:

// config/services.php
...
'green_api' => [
    'isEnable' => env('GREEN_API_ENABLE') ?? 0,
    'apiUrl' => env('GREEN_API_URL') ?? 'https://1103.api.green-api.com/',
    'instanceId' => env('GREEN_API_INSTANCEID'),
    'token' => env('GREEN_API_TOKEN'),
    'isMalaysiaMode' => env('GREEN_API_MALAYSIA_MODE') ?? 0,
    'isDebug' => env('GREEN_API_DEBUG_ENABLE') ?? 0,
    'debugReceiveNumber' => env('GREEN_API_DEBUG_RECEIVE_NUMBER'),
],
...

Usage

You can use the channel in your via() method inside the notification:

use Illuminate\Notifications\Notification;
use NotificationChannels\GreenApi\GreenApiMessage;
use NotificationChannels\GreenApi\GreenApiChannel;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [GreenApiChannel::class];
    }

    public function toGreenApi($notifiable)
    {
        return GreenApiMessage::create("Task #{$notifiable->id} is complete!");
    }
}

In your notifiable model, make sure to include a routeNotificationForGreenApi() method, which return the phone number.

public function routeNotificationForGreenApi()
{
    return $this->mobile; //depend what is your db field
}
// routes/web.php
$this->get('preview-notification', function () {

    $user = User::where('email', 'shiroamada@shiro.my')->first();
     Notification::route('greenapi', $user->mobile)->notify(
         new \App\Notifications\SendTest()
     );

Available methods

content(): Set a content of the notification message.

To send a next new line message, in PHP please use double quote "\n"

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please use the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-15