This example shows how to use LINE Notify service.
Instead of creating a LINE official account and use Mesaging API to push messages to users.
LINE Notify enables you to send messages without a LINE official account.
LINE Notify uses OAuth 2 for web service providers.
You can easily implement a service and send messages to users on LINE with LINE Notify.
The sequence diagram is shown and the flow is explaned below:
- User visits your website(service provider).
- Your website redirect user to LINE OAuth2 authorization endpoint.
- User selects a channel to send notifications to.
- Redirect to
callback_url
you registered on LINE notify service page withcode
. - You send a
HTTP POST
request to LINE OAuth2 token endpoint. - Receive the access token and store it.
- Call notification API with the access token to send notifications.
1. Go to LINE Notify and log in your LINE account
- Fill in "http://localhost:3000/index" for
Service URL
. - Fill in "http://localhost:3000/callback" for
Callback URL
. - Go to Manage registered services and remember your Client ID and Client Secret.
- In
src/index.html
andsrc/notify.js
, replaceYOUR_CLIENT_ID
with your real client ID. - In
src/notify.js
, replaceYOUR_CLIENT_SECRET
with your real client secret.
yarn
to install dependencies.yarn start
to start localhost server.
Try on http://localhost:3000
- Press the button LINE Notify.
- You are redirected to LINE OAuth2 authorization endpoint to log in your LINE account, and select a chat to send notifications to.
- You are redirected to your
callback_url
, which is [http://localhost:3000/callback], withcode
. - Enter the message you want to send to the chat.
- In the step, your website sends an
HTTP POST
request withcode
to your backend server. - The backend server sends an
HTTP POST
request to LINE OAuth2 endpoint to get anaccess token
. - The backend server calls notification API with
access token
to send to notification.
- In the step, your website sends an
The API rate limit of an API can be called (per token) on each service is 1000/hour.
You can check your token status via GET https://notify-api.line.me/api/status
.
Before you exceed the rate limit and call notification API successfully, you will receive a response with the header denoting the API rat e limit status.
Header name | Description |
---|---|
X-RateLimit-Limit | The limit of API calls per hour |
X-RateLimit-Remaining | The number of possible remaining API calls |
X-RateLimit-ImageLimit | The limit of Uploading image per hour |
X-RateLimit-ImageRemaining | The number of possible remaining Uploading image |
X-RateLimit-Reset |
The time when the limit is reset (UTC epoch seconds) ex:1472195604 |