PHP code example of chez14 / line-notify-sdk

1. Go to this page and download the library: Download chez14/line-notify-sdk 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/ */

    

chez14 / line-notify-sdk example snippets


$api = new LINE\Notify\Api([
    "client_id" => '0123456789',
    "client_secret" => '00112233445566778899aabbccddeeff'
]);

$login = LINE\Notify\Token::generateAuthUrl($api, "http://localhost:8087/oauthcallback.php", "stateA");
// will produce:
// https://notify-bot.line.me/oauth/authorize?response_type=code&client_id=0123456789&redirect_uri=http%3A%2F%2Flocalhost%3A8087%2Foauthcallback.php&scope=notify&state=stateA

// On oauthcallback.php
$token = LINE\Notify\Token::fromAuthCode($lineApi, $_GET['code'], "http://localhost:8087/oauthcallback.php");
$api->setToken($token);

$notify = new LINE\Notify\Notify($api);
$notify->notify("HELLO!", null, 1, 106);