7elven / Simple-PHP-LINE-BOT

Simple PHP Line Bot using cURL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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/

About

Simple PHP Line Bot using cURL

License:MIT License


Languages

Language:PHP 100.0%