eric0324/lotify

Lotify 是一个 LINE Notify 客户端 SDK,可以帮助您快速构建 Notify 机器人。

v1.0.1 2020-05-03 09:13 UTC

This package is auto-updated.

Last update: 2024-09-29 05:48:47 UTC


README

License: MIT PRs Welcome PHP version

Lotify 是一个 LINE Notify 客户端 SDK,可以帮助您快速构建 Notify 机器人。

用法

您需要一个 LINE 账户 并创建一个 Notify: 链接

安装包

composer require eric0324/lotify

初始化实例

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'}

发送带有贴纸的消息

您可以在这里找到 stickerId 和 stickerPackageId

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

通过图片 URL 发送消息

$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'}

许可协议

MIT © Eric Wu