Giter Club home page Giter Club logo

linelogin-forphp's Introduction

Line Login For PHP unofficial

Build Status

環境要求

  • PHP 5.4 以上
  • PHP-CURL
  • Laravel 5.2 以上 (非必要)

Laravel 安裝教學

  • Composer 安裝
composer require littlechou/line-login
  • 在 .env 新增以下參數 並填寫相關 LINE API 所需資訊
LINE_CLIENT_ID = 
LINE_REDIRECT_URI = 
LINE_CLIENT_SECRET = 
LINE_SCOPE = 
  • 調整 app\config\app.php 找到 providers 並新增
LittleChou\LineLogin\ServiceProvider\LineLoginServiceProvider::class,
  • 調整 app\config\app.php 找到 aliases 並新增
'LineProfile' => LittleChou\LineLogin\Facades\LineProfile::class,

使用說明

  • 在你的 Blade 裡面 填寫以下程式碼,會產生認證網址
<a href="@lineloginlink()">Line Login</a>
  • 接著 在你 CallBack 的 Controller 裡面的 function 中 填寫以下程式碼 即可取得 Line 使用者資訊,並使用命名空間
use LineProfile; 

public function lineCallBackProfile(Request $request){

    $code = $request->get('code');
    
    $profile = LineProfile::get($code);
    
}

非 Laravel 環境下使用方法

以下為 CodeIgniter 3 做為範本

use LittleChou\LineLogin\ConfigManager;
use LittleChou\LineLogin\LineProfiles;
use LittleChou\LineLogin\LineAuthorization;

class LineController extends CI_Controller {

    private $lineConfig;

    public function __construct() {
        $config = new ConfigManager();
        $config->setRedirectUri("YOUR-REDIRECT-URI")
            ->setScope("YOUR-SCOPE")
            ->setClientSecret("YOUR-CLINET-SECRET")
            ->setClientId("YOUR-CLIENT-ID");
        $this->lineConfig = $config;
    }

    /**
     * 產生連結
     *
     */
    public function lineLogin() {
        $auth = new LineAuthorization($this->lineConfig);
        echo $auth->createAuthUrl();
    }

    /**
     * 取得使用者資訊
     *
     */
    public function getLineProfile() {
        $code = $this->input->get('code');

        $lineProfile = new LineProfiles($this->lineConfig);

        $profile = $lineProfile->get($code);
    }
}

linelogin-forphp's People

Contributors

slps970093 avatar

Stargazers

Mesak avatar Pang avatar  avatar Firch Tsai avatar gson avatar Wei Zhang avatar Ernest Chiang avatar

Watchers

James Cloos avatar  avatar

linelogin-forphp's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.