jeurboy/line-sdk

There is no license information available for the latest version (0.1.1) of this package.

Line SDK for PHP.

0.1.1 2018-12-18 08:46 UTC

This package is not auto-updated.

Last update: 2024-04-17 18:57:51 UTC


README

PHP Line SDK Class

Line Notify Document

Requirement

Composer

Install the latest version with composer

composer require jeurboy/line-php-sdk

Generate Line Notify Token

https://notify-bot.line.me/my/

Notify Usage

Example : Simple notify with text message

namespace Jeurboy\LineSdk;

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

$receipientToken = '========== Notify token ==========';

$line_noti = Line::notify($receipientToken);

$line_text = Line::textMessage();
$line_text->setMessage('Test');

if ($line_noti->send( $line_text ) !== true) {
    echo $line_noti->getErrorMessage()."\n";
} else {
    echo "Success\n";
}

Chat bot auto reply usage

Example : Chat bot and auto reply with text message

namespace Jeurboy\LineSdk;

require_once __DIR__ . '/../vendor/autoload.php'; // Autoload files using Composer autoload

$accessToken = '========== Access token ==========';
$channelSecret = '========== Channel secret key ==========';

$request = file_get_contents('php://input');   // Get request content

$line_bot = Line::bot($accessToken, $channelSecret);

$line_text = Line::textMessage();

$parser = Line::eventParser($request);
$events = $parser->parseEvents();

foreach ($events as $event) {
    switch ($event->getType()) {
        case 'Text':
            $line_text->setMessage('Test reply : '.$event->getMessage());
            $line_bot->send($event->getReplyToken(), $line_text);

            break;
    }
}

License

Jeurboy License