wilkques/line-login-sdk-php
最新稳定版本:v6.0.0
Composer 安装命令:
composer require wilkques/line-login-sdk-php
包简介
LINE Login SDK for PHP
README 文档
README
Installation
composer require wilkques/line-login-sdk-php
Scopes
| Scope | Profile | ID Token (including user ID) |
Display name in ID token |
Profile image URL in ID token |
Email address in ID token |
|---|---|---|---|---|---|
| profile | ✓ | - | - | - | - |
| profile%20openid | ✓ | ✓ | ✓ | ✓ | - |
| profile%20openid%20email | ✓ | ✓ | ✓ | ✓ | ✓(※) |
| openid | - | ✓ | - | - | - |
| openid%20email | - | ✓ | - | - | ✓(※) |
How to use
-
Authorization
use Wilkques\LINE\LINE; $line = new LINE('<CHANNEL_ID>'); // or $line = LINE::clientId('<CHANNEL_ID>'); $code = $_GET['code'] ?? null; if ($code) { $token = $line->clientSecret('<CHANNEL_SECRET>')->token($code, '<REDIRECT_URI>'); $userProfile = $line->userProfile($token->accessToken()); exit; } $url = $line->generateLoginUrl([ // Callback URL: https://developers.line.biz/console/channel/<channel id>/line-login 'https://yourdomain.com', // Permissions requested from the user: https://developers.line.biz/en/docs/line-login/integrate-line-login/#scopes [ 'profile', 'openid', 'email' ] ]); // or $url = $line->generateLoginUrl([ // Callback URL: https://developers.line.biz/console/channel/<channel id>/line-login 'redirect_uri' => $url, // Permissions requested from the user: https://developers.line.biz/en/docs/line-login/integrate-line-login/#scopes 'scope' => ['openid', 'openid'] ]); header('Location: '.$url);
-
PKCE Authorization
- command
composer require wilkques/pkce-phpwilkques/pkce-php -
use Wilkques\LINE\LINE; use Wilkques\PKCE\Generator; $line = new LINE('<CHANNEL_ID>'); // or $line = LINE::clientId('<CHANNEL_ID>'); $pkce = Generator::generate(); $code = $_GET['code'] ?? null; if ($code) { $codeVerifier = $_GET['state'] ?? null; $token = $line->clientSecret('<CHANNEL_SECRET>')->token($code, '<REDIRECT_URI>', $codeVerifier); $userProfile = $line->userProfile($token->accessToken()); exit; } $codeVerifier = $pkce->getCodeVerifier(); $codeChallenge = $pkce->getCodeChallenge(); $url = $line->generatePKCELoginUrl([ // Callback URL: https://developers.line.biz/console/channel/<channel id>/line-login 'https://yourdomain.com', // Permissions requested from the user: https://developers.line.biz/en/docs/line-login/integrate-line-login/#scopes [ 'profile', 'openid', 'email' ], $codeVerifier, $codeChallenge ]); // or $url = $line->generatePKCELoginUrl([ // Callback URL: https://developers.line.biz/console/channel/<channel id>/line-login 'redirect_uri' => $url, // Permissions requested from the user: https://developers.line.biz/en/docs/line-login/integrate-line-login/#scopes 'scope' => ['openid', 'openid'], 'state' => $codeVerifier, 'code_challenge' => $codeChallenge, ]); header('Location: '.$url);
- command
Client CURL Setting
-
setCurlOptionPHP CURL Setting$line->setCurlOption(<CURL OPTION>, <Value>); // e.g. $line->setCurlOption(CURLOPT_TIMEOUT, 100);
REFERENCE
统计信息
- 总下载量: 307
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-13