PHP code example of wilkques / line-notify

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

    

wilkques / line-notify example snippets


    use Wilkques\LineNotify\Notify;

    $notify = new Notify('<CHANNEL_ID>');
    $url = $notify->generateSubscribeUrl($options);
    // or
    $url = Notify::clientId('<CHANNEL_ID>')->generateSubscribeUrl($options);
    

    use Wilkques\LineNotify\Notify;

    $notify = new Notify('<CHANNEL_ID>', '<CHANNEL_SECRET>');
    $token = $notify->requestToken($_GET['code'])->accessToken();
    // or
    $token = Notify::clientId('<CHANNEL_ID>')
    ->clientSecret('<CHANNEL_SECRET>')
    ->requestToken($_GET['code'])
    ->throw() // throw exception
    ->accessToken();
    

    use Wilkques\LineNotify\Notify;
    use Wilkques\LineNotify\Message;

    // Builder Message
    $message = new Message('<Notify Text>');
    // or
    $message = Message::message('<Notify Text>');

    // Get Response
    $response = (new Notify)->token('<Access Token>')->sendMessage($message);
    // or
    $response = Notify::token('<Access Token>')->sendMessage($message);

    $response->throw(); // throw exceptions
    // or
    $response->throw(function (\Wilkques\Http\Response $response, \Wilkques\Http\Exceptions\RequestException $exception) {
        // code
        // return exceptions
    });