Catalogue
Writing a Dead-Simple LINE Bot API in PHP

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.

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!

kenzo0107

kenzo0107