Download the PHP package syllistudio/line-messaging without Composer
On this page you can find all versions of the php package syllistudio/line-messaging. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download syllistudio/line-messaging
More information about syllistudio/line-messaging
Files in syllistudio/line-messaging
Informations about the package line-messaging
Line Messaging For PHP
About Line Messaging
This package provides easy integration with LINE Message API interfaces. The package contains 2 essential parts. First, a webhook that handles events sent from LINE Messaging API. Second, simple methods to communicate using Line Messaging API.
Installation
This package can be installed through Composer.
The service provider will automatically register itself. After that, You need to add our Syllistudio\LineMessaging\LineMessagingProvider::class
to the array of Service Providers in file config/app.php
You must publish the config file with:
This is the contents of the config file that will be published at config/line-messaging.php
:
You can customize your channel_secret
and channel_access_token
here or define it in your environment variables.
Note: Find both channel_secret
and channel_access_token
in your console LINE channel.
Usage
Mechanism to work with LINE bot is a communication between the server of your bot application and the LINE Platform. When a user sends your bot a message, LINE Messaging API will send a request to your webhook URL. The webhook created with this package will provide methods to handle those events sent from LINE Messaging API. To response to those events or communicate with your contacts, this package provide methods that let the server sends a request to the LINE Platform to respond to the user. Requests are sent over HTTPS in JSON format.
Create Webhook URL
You can create it easily in your routing. You will first need to create Controller and use our trait LineWekhookReceiver
. After that, in the route file of your app, you must create a route to the created Controller Route::post('/webhook', 'YourControllerName@handleWebhook')
. This will give you the webhook URL and you will need to set this webhook URL in your LINE console to integrate your app with LINE messaging API.
These are pre-defined methods that handle events received from our webhook. You can find the full list of events types and its detail information here in the Line Messaging API documentation.
NOTE: Line event responses will not have csrf-token included thus you must add your route to the except array of the VerifyCsrfToken middleware.
Sending Message
This package provides LineMessaging
trait that support below messaging methods.
- Send reply message
- Send push message
Send Reply Message
You can send messages back to users, groups, and rooms from a replyToken
received from webhook events. Just add LineMessaging
trait in to your controller. The trait will adds method replyMessage($replyToken, MessageBuilder $messages)
into your controller.
Because the replyToken
becomes invalid after a certain period of time, responses should be sent as soon as a message is received. Reply tokens can only be used once.
Send Push Message
You can send messages to a user
, group
, or room
at any time by method pushMessage($to, MessageBuilder $messages)
.
Use a userId
, groupId
, or roomId
value returned from webhook event object.
NOTE: Do not use the LINE ID
found on the LINE app.
License
The LineMessaging is open-sourced software licensed.