PHP code example of oh-sky / line-trialbot

1. Go to this page and download the library: Download oh-sky/line-trialbot library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oh-sky / line-trialbot example snippets



namespace Foo;

ot\Sender;
use OhSky\LineTrialBot\RequestHandler;

$sender = new Sender(
    YOUR_CHANNEL_ID,
    YOUR_CHANNEL_SECRET,
    YOUR_CHANNEL_MID
);

$requestBodyJson = file_get_contents('php://input');
$eventList = RequestHandler::getEventList($requestBodyJson);

foreach ($eventList as $event) {
    // Sending TEXT
    $sender->sendText(
        [$event->content->from],
        "text to send"
    );

    // Sending Image
    $sender->sendImage(
        [$event->content->from],
        'IMAGE_URL',
        'THUMBNAIL_URL'
    );

    // Sending Video
    $sender->sendVideo(
        [$event->content->from],
        'VIDEO_URL',
        'THUMBNAIL_URL'
    );

    // Sending Audio
    $sender->sendAudio(
        [$event->content->from],
        'AUDIO_URL',
        'AUDIO_LENGTH_MILLI_SECOND'
    );

    // Sending Location
    $sender->sendLocation(
        [$event->content->from],
        'TEXT',
        'TITLE',
        latitude, //float
        longitude //fload
    );

    // Sending Sticker
    $sender->sendSticker(
        [$event->content->from],
        'STICKER_ID',
        'STICKER_PACKAGE_ID',
        'STICKER_VERSION'
    );
}