PHP code example of eric0324 / lotify

1. Go to this page and download the library: Download eric0324/lotify 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/ */

    

eric0324 / lotify example snippets


use Ericwu\Lotify\Lotify;

$channelSecret = "<YOUR_CHANNEL_SECRET>";
$clientId = "<YOUR_CLIENT_ID>";
$redirectUri = "<YOUR_REDIRECT_URI>";
$lotify = new Lotify([
    'channelSecret'=> $channelSecret,
    'clientId' => $clientId,
    'redirectUri' => $redirectUri
]);

$link = $lotify->getAuthLink('<RANDOM_STRING>');
echo($link);
# https://notify-bot.line.me/oauth/authorize?scope=notify&response_type=code&client_id=QxUxF..........i51eITH&redirect_uri=http%3A%2F%2Flocalhost%3A5000%2Fnotify&state=foo

$access_token = $lotify->getAccessToken('<NOTIFY_RESPONSE_CODE>');
echo($access_token);
# N6g50DiQZk5Xh...25FoFzrs2npkU3z

$status = $lotify->getStatus('<YOUR_ACCESS_TOKEN>');
echo($status);
# {'status': 200, 'message': 'ok', 'targetType': 'USER', 'target': 'Eric wu'}

$response = $lotify->sendMessage(access_token='<YOUR_ACCESS_TOKEN>', message='<This is notify message>');
echo($response);
# {'status': 200, 'message': 'ok'}

$response = $lotify->sendMessageWithSticker('<YOUR_ACCESS_TOKEN>', '<This is notify message>', '<sticker_id>', '<sticker_package_id>');
echo($response);
# {'status': 200, 'message': 'ok'}

$image = $lotify->sendMessageWithImageUrl(
    '<YOUR_ACCESS_TOKEN>',
    '<This is notify message>',
    '<IMAGE_THUMBNAIL_URL>',
    '<IMAGE_FULLSIZE>',
);
echo($image);
# {'status': 200, 'message': 'ok'}

$revoke = $lotify->revoke('<YOUR_ACCESS_TOKEN>');
echo($revoke);
# {'status': 200, 'message': 'ok'}