wilkques/line-notify

v1.0.0 2022-03-10 04:07 UTC

This package is auto-updated.

Last update: 2024-10-09 08:03:21 UTC


README

Latest Stable Version License

composer require wilkques/line-notify

How to use

  1. Generate URL

    use Wilkques\LineNotify\Notify;
    
    $notify = new Notify('<CHANNEL_ID>');
    $url = $notify->generateSubscribeUrl($options);
    // or
    $url = Notify::clientId('<CHANNEL_ID>')->generateSubscribeUrl($options);
  2. GET Access Token

    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();
  3. Push Message

    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
    });
  4. Methods

    1. Response see REFERENCE Http Client

REFERENCE

  1. Official
  2. Http Client