Writing a Dead-Simple LINE Bot API in PHP
Overview
I wrote a script for the much-talked-about LINE Bot API in PHP.
As simple as possible = easy to customize
That was the goal, so I tried to limit the places you need to modify in order to use it.
What I Built
Type any random text → it replies “hello”
Type “perfect” → it replies “human”
It’s a truly simple thing that just responds like that.
If you customize that logic part, you can make your own bot.
Environment
- Sakura Rental Server VPS, CentOS release 6.7 (Final)
- PHP 5.6.16
For SSL, I used the free StartSSL. For obtaining and configuring it, please refer to the following.

無料SSL証明書発行しセキュリティでA+を取る! 〜Apache編〜 - 長生村本郷Engineers'Blog
以下に移行しました。 kenzo0107.github.io
The Script
function getMessage is where you decide the message you want the bot to reply with.
If you call another API there, scrape a site, or otherwise fetch some information and return it, you’ve got yourself a simple message-replying LINE bot.
Here’s How It Looks!

