PHP code example of fcorz / laravel-line-notify
1. Go to this page and download the library: Download fcorz/laravel-line-notify library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fcorz / laravel-line-notify example snippets bash
php artisan vendor:publish --provider="Fcorz\LaravelLineNotify\LaravelLineNotifyServiceProvider"
php
// get access_token by code
LaravelLineNotifyFacade::getAccessToken("O97YoWeYMV6vW3uYPFgPAC");
// notify
$message = (new LaravelLineMessage())->message('hello world');
LaravelLineNotifyFacade::sendNotify($message, "access_token");
php
public function routeNotificationForLine($notification)
{
return $this->notify_access_token;
}
php
use App\Models\UserMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Notification;
class LineNotification extends Notification implements ShouldQueue
{
use Queueable;
protected $message;
public function __construct($message, $delay = 0)
{
$this->queue = 'notification';
$this->delay = $delay;
$this->message = $message;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['line'];
}
/**
* @param $notifable
* @return LineTemplateService
*/
public function toLineNotify($notifable)
{
return (new LaravelLineMessage())->message($this->message);
}
}
php
$receiver->notify(new LineNotification('hello world'));