PHP code example of whchi / laravel-linebot-wrapper
1. Go to this page and download the library: Download whchi/laravel-linebot-wrapper 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/ */
whchi / laravel-linebot-wrapper example snippets
return [
'channel_access_token' => 'find it in your LINE console'
'channel_secret' => 'find it in your LINE console'
];
public function __construct()
{
$context = app('LINEBotContext');
}
...
public function entryPoint(Request $request)
{
$lineMsg = $request->all();
$events = collect($lineMsg['events']);
$events->map(function($event) {
$this->context->setContext($event);
... do whatever you want...
});
}
// after setContext
event(new SaveLineBotSessionEvent($event));
$this->context->initState([
'status' => 1,
'isAuth' => ['departA' => true, 'departB' => false]
]);
// must execute after setContext
$this->context->buildState();
// max 150 user id
// @see https://developers.line.biz/en/reference/messaging-api/#send-multicast-message
$this->context->pushMulticast(array $memberIdList, string $altText, array $templateList)