PHP code example of notification-custom-line-channel / line-bot

1. Go to this page and download the library: Download notification-custom-line-channel/line-bot 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/ */

    

notification-custom-line-channel / line-bot example snippets




return [

    // ...

    'line-bot' => [
        'channel_access_token' => env('LINE_CHANNEL_ACCESS_TOKEN'),
    ],

];



namespace App\Http\Controllers;

use App\Models\User;
use NotificationChannels\Line\LineChannel;
use NotificationChannels\Line\LineMessage;
use Illuminate\Notifications\Notification;

/**
 * Sample Code.
 */
class TestController extends Controller
{
    public function notifyToUser()
    {
        $user = new User();
        $user->notify(new LineNotification());
    }
}

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

    public function toLine($notifiable)
    {
        return LineMessage::create(
            'line_user_id',
            'Hello world.'
        );
    }
}