ホーム 暮らし The Shock of the LINE Notify Service Termination!

The Shock of the LINE Notify Service Termination!

雨宮 千夏 雨宮 千夏 • 更新: • 公開: • 読了約 26 分
目次

The alternative is LINE Messaging API PUSH

n631d95c201a8

I have been using LINE Notify quite conveniently, but it will end its service on March 31, 2025 (LINE's announcement is here).

In addition to introducing it in "Programming, Electronics, and LINE Notifications", I also frequently use LINE Notify for projects I use daily. It seems that similar notifications can be achieved with the "Messaging API". However, the number of messages that can be sent for free is limited to 200 per month.

For my purposes, which involve one regular daily communication and emergency communications, 200 messages per month is not a problem. Rewriting the sketch does not seem to be complicated either.

The Messaging API is originally a feature for creating "bots". It seems that to replace LINE Notify, I will be using a part of the bot functionality.

Differences between LINE Notify and Messaging API

LINE Notify registers the service on the https://notify-bot.line.me/ website. You invite LINE Notify to a group chat using the LINE app on your smartphone. After that, you could send messages to the group chat by POSTing them from an M5StickC to LINE Notify.

On the other hand, with the Messaging API, you register a provider and channel on the https://developers.line.biz/ website. You add it as a friend by scanning the QR code from the website with the LINE app on your smartphone and invite it to a group chat. After that, you POST a message from the M5StickC to the Messaging API PUSH. At this time, you need to specify a "user ID" or "group ID" as the destination. (To be precise, if you POST to BROADCAST, you do not need an ID to specify the destination, but it will be sent to all friends.)

The major difference between LINE Notify and the Messaging API is that the former is a one-way communication from system to user, while the latter is a two-way communication between system and user. Therefore, the Messaging API requires a web server to run the "bot" that receives messages from users.

Now, let's begin the long preparation to obtain the "user ID" and "group ID".

Renting a web server

If you google "free hosting service that can use SSL", you will find "XREA" and "Shin Free Server" as web servers that are permanently free. For low-cost servers, there are options like Lolipop at 198 yen/month or Sakura Internet at an equivalent of 121 yen/month.

There are two essential requirements for a web server.
(1) The website must be able to be HTTPS-enabled
(2) You must be able to deploy server-side applications

A "bot" is a server-side application that runs on a web server. The programming language can be anything such as Perl, Python, Ruby, Java, or PHP. I think many web servers support PHP.

Creating a bot

Let's create a bot while following the LINE instructions. Since there are detailed explanations on the LINE site, I will omit the fine details.

1. Let's start with the Messaging API

Work on your PC browser.

Follow the instructions to create an account. For the questions about "purpose of use" and "industry", choose the ones that best match your own.

Select "️Settings". Next, select "Messaging API" from the left-hand menu, and click "Use Messaging API". Select an existing provider or add a new one. You can use Japanese for the provider name.

LINE Developers Console and check the channel you created.

Click on the channel you created and select "Messaging API settings".

  • Webhook URL
    Enter the URL where you will host the "bot" server-side application. It must be HTTPS to be accepted. (For example, https://example.com/receive.php)

  • Use webhook
    ON
    Set this to.

  • Allow bot to join group chats and multi-person chats
    Click "Edit", and set "Allow bot to join group chats and multi-person chats" under "Feature usage" to Enabled. This will allow you to send notifications to group chats.

  • Response messages
    Click "Edit" to change the settings. To achieve the same functionality as LINE Notify, set Chat: OFF, Greeting message: OFF, Webhook: ON, and Response messages: OFF.

  • Channel access token
    Click "Issue" to issue a Channel access token (long-lived).

LINE Developers Console Reload the page and check. It is okay if the Webhook URL is correct, and Use webhook: ON, Allow bot to join group chats and multi-person chats: Enabled, and Channel access token (long-lived) are displayed.

2. Create a bot

Open the LINE app on your smartphone.

Display the Messaging API settings (Figure 4) for the channel in the LINE Developers Console, scan the QR code, and add it as a friend. You should now be able to find it in the LINE app under "Home" -> "Friends" -> "Official Accounts".

Open the group chat to which you want to send notifications and invite the official account.

The preparation on the LINE side is now complete. From here on, it is the web server configuration.

3. Create a server-side application

Create a server-side application in PHP to obtain the "User ID" and "Group ID" of the destination. The server-side application receives message data sent from the group chat via Webhook and saves it to a file.

https://example.com/receive.php

<?php
const RECEIVED_DATA_FILENAME = './received_data.txt';

$json_string = file_get_contents('php://input');
if ($json_string) 
 file_put_contents(RECEIVED_DATA_FILENAME, $json_string);

?>

Upload the server-side application file receive.php to the Web server using the tools provided by your rental server hosting service, and save it to the location you set as the LINE Developers Console for the Webhook URL.

That is all there is to the Web server configuration.

It was a long process, but now you are finally ready to obtain the "User ID" and "Group ID".

Obtaining the User ID and Group ID

In a LINE group chat, write some text (for example, "Hello"). JSON text like the following will be saved in the received_data.txt file. Please read out received_data.txt using the tools provided by your rental server hosting service.

In a chat where you are the only member, there is no groupId line. Also, "type" will be "user".

Once the "Group ID" is known, please set the Use Webhook: OFF setting that you configured in "1. Let's Start with Messaging API".

received_data.txt Line breaks and indentation added for readability; IDs are dummy values

 "destination":"Ueff18e55bc57ecdc417585b75507eb92",
 "events":
 [
 
 "type":"message",
 "message":
 
 "type":"text",
 "id":"534799865415729539",
 "quoteToken":"kauFWyrYgsZpLzQ4In29MhDMrWuccP9DuJSLsb5zkRJhUSh7TA2t_9BxXM4MlaRakNNdKpuhO-jMI12UqZC-GW_qvvU0InrksOIbM61wZwWVhHq8gAGkjdL7AF46GDE_ewi6vSQTv47FUhA3OAwwWA",
 "text":"こんにちは"
 ,
 "webhookEventId":"01JCNKEK5G93VD31WC38TZ9E8R",
 "deliveryContext":
 
 "isRedelivery":false
 ,
 "timestamp":1731596864183,
 "source":
 
 "type":"group",
 "groupId":"C10cdfc250a2808cce4baa9c6478b7e6f",
 "userId":"U277f0e293c51fa7a3c4093aefa640cd7"
 ,
 "replyToken":"c284f35ba7df82a384af39df748ffc13",
 "mode":"active"
 
 ]

Sending a message from M5StickC

Now that the "Group ID" is known, you will be able to send messages to the group chat.

Let's modify the sketch from "Programming, Electronics, and LINE Notifications".

Change the String query and String request generation statements in void line_notify(String msg) as shown in the sketch below. Also, replace the constant const char host with "api.line.me". The Content-Type will be application/json.

const char* host = "api.line.me"; // LINE Messaging API ホスト
const char* token = "*"; // LINEチャネルアクセストークン
const char* groupid = "C10cdfc250a2808cce4baa9c6478b7e6f"; // グループID(ユーザIDでもよい)
...中略...
WiFiClientSecure client;
...中略...
// String msgを送る場合
String query = String() + 
 " \"to\": \"" + groupid + "\"," + 
 "\"messages\": [" + 
 " \"type\": \"text\", " + 
 "\"text\": \"" + msg + "\" " + 
 "]" + 
 "";
String request = String() + 
 "POST /v2/bot/message/push HTTP/1.1\r\n" + 
 "Host: " + host + "\r\n" + 
 "Authorization: Bearer " + token + "\r\n" + 
 "Content-Length: " + query.length() + "\r\n" + 
 "Content-Type: application/json\r\n\r\n" + 
 query + "\r\n";
client.print(request);
...以下略...

Results

LINE Notify and Messaging API PUSH function in the same way. The LINE Notify icon is a bell mark and cannot be changed, but with the Messaging API, you can assign any icon you like.

The "Push Button A (Top Button)" and "Pushed B (Side)" in Figure 5 are messages sent from the M5StickC Plus. There is no reply to the "Hello" sent from the smartphone.

As mentioned at the beginning, the number of messages that can be sent for free is limited to 200 per month, so it is difficult to use for purposes where messages are generated frequently.

Messaging API PUSH is a one-way message transmission just like LINE Notify, so a Webhook is unnecessary. It is troublesome to host a Web server just for the one-time task of obtaining the "Group ID".

Correction and Apology

The "User ID" and "Group ID" differ for each provider.
It seems that the groupId and userId for Provider A are different from those for Provider B.

Unaware of this, I made the LINE Official Account I had set up public. To everyone who used it, I imagine it did not work as expected. I am very sorry. I would like to correct this and offer my apologies.

Reference

License

The source code for this page may be freely copied, modified, and distributed. You may also use it for commercial purposes, but I assume no responsibility whatsoever.

Update History

  • September 7, 2025: Added "XREA" to "Renting a Web Server."

同じカテゴリの記事

雨宮 千夏
デジタルマーケター 雨宮 千夏
プロフィールを見る →

アイドルと音楽シーンの取材を担当。公式サイトの公演情報、リリース告知、公開チャートを照合してから構成しています。

おすすめの関連記事