jeurboy/line-sdk
Composer 安装命令:
composer require jeurboy/line-sdk
包简介
Line SDK for PHP.
README 文档
README
PHP Line SDK Class
Requirement
- PHP 7+
- guzzlehttp
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
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-12-12