Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.2 KB

README.md

File metadata and controls

60 lines (47 loc) · 1.2 KB

Simple-PHP-LINE-BOT

Simple PHP LINE BOT using cURL without line SDK
by Nontachai Korninai

Setting

go to file setting.php
public function getChannelAccessToken(){
	$channelAccessToken = "<YOUR CHANNEL ACCESS TOKEN>";
	return $channelAccessToken;
}
        
public function getChannelSecret(){
	$channelSecret = "<YOUR CHANNEL SECRET>";
	return $channelSecret;
}

Example : Simple BOT

When you finished setting, Create new index.php

reply

require_once __DIR__ . '/lineBot.php';
$bot = new Linebot();

$text = $bot->getMessageText(); //when user send text to bot	
$bot->reply($text); // bot reply to user

get User Id

$userId = $bot->getUserId();

Push Text

$bot->pushText($userId, 'Hello Simple Text!');

Push Image

$imageUrl = "https://example.com/panda.jpg";
$bot->pushImage($userId, $imageUrl);

Push Video

$videoUrl = "https://example.com/avengers.mp4";
$coverImage = "https://example.com/cover.jpg";
$bot->pushVideo($userId, $videoUrl, $coverImage);

About LINE Messaging API

Please refer to the official API documents for details.

en: https://devdocs.line.me/en/

ja: https://devdocs.line.me/ja/