kaleidpixel / line-oauth
Integrating LINE Login with your web app.
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/kaleidpixel/line-oauth
This package is auto-updated.
Last update: 2025-10-23 19:40:42 UTC
README
Integrating LINE Login with your web app.
Requirements
This package requires PHP >=5.4
Installation
Install via composer - edit your composer.json to require the package.
{
"require": {
"kaleidpixel/line-oauth": "0.*"
}
}
Then run composer update in your terminal to pull it in.
Or use composer require kaleidpixel/line-oauth
How to
login.php
<?php require_once dirname(dirname(__FILE__)) . '/vendor/autoload.php'; use KaleidPixel\OAuth\LineOAuth; $connection = new LineOAuth(API_KEY_LINE, API_SECRET_LINE); $_SESSION['user']['oauth_token'] = $connection->state; $_SESSION['user']['oauth_provider'] = 'line'; header("Location: {$connection->oauthUrl(OAUTH_CALLBACK_URL)}");
callback.php
<?php require_once dirname(dirname(__FILE__)) . '/vendor/autoload.php'; use KaleidPixel\OAuth\LineOAuth; if (isset($_REQUEST['code']) && $_REQUEST['state'] === $_SESSION['user']['oauth_token']) { $connection = new LineOAuth(API_KEY_LINE, API_SECRET_LINE, $_SESSION['user']['oauth_token']); $token = $connection->getToken($_REQUEST['code'], OAUTH_CALLBACK_URL); if (!is_null($token)) { $user = $connection->getUser($token); if(!empty($user)) { $_SESSION['user']['provider'] = $_SESSION['user']['oauth_provider']; $_SESSION['user']['provider_id'] = $user->userId; $_SESSION['user']['name'] = $user->displayName; } } } var_dump($_SESSION);