wilkques/line-login-sdk-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wilkques/line-login-sdk-php

最新稳定版本:v6.0.0

Composer 安装命令:

composer require wilkques/line-login-sdk-php

包简介

LINE Login SDK for PHP

README 文档

README

Latest Stable Version License

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

  1. 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);
  2. PKCE Authorization

    1. command composer require wilkques/pkce-php wilkques/pkce-php
    2. 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);

Client CURL Setting

  1. setCurlOption PHP CURL Setting

    $line->setCurlOption(<CURL OPTION>, <Value>);
    
    // e.g.
    
    $line->setCurlOption(CURLOPT_TIMEOUT, 100);

REFERENCE

  1. Official
  2. LINE Login Official
  3. PKCE support for LINE Login

统计信息

  • 总下载量: 307
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固