Code Monkey home page Code Monkey logo

fashionguide's Introduction

FashionGuide Oauth2 PHP SDK

該套件提供 FashionGuide Oauth2 取得資料

版本需求

  • PHP 5.6(含)以上
  • Laravel 5.3(含)以上

安裝

  1. 透過 composer 安裝

composer require fashionguide/oauth2

  1. 加入 provider

    config/app.php

    'providers' => [
        \FashionGuide\Oauth2\ServiceProvider::class,
    ]
  2. 加入 alias

    config/app.php

    'aliases' => [
       'FG' => \FashionGuide\Oauth2\Facade::class,
    ]

Config

預設於 .env 取得

.env

FG_CLIENT_ID=1
FG_CLIENT_SECRET=ChfjlvqDVlpKzrKf0x7vo0h05jYkMKhs61RTGlYZ
FG_REDIRECT_URI=http://localhost:8000/callback

或是 publish config 自己定義 config

php artisan vendor:publish --provider="FashionGuide\Oauth2\Providers\ServiceProvider"

API Document

// todo

Usage

取得 user 資料

  1. 先取得登入網址
<?php

use \FashionGuide\Oauth2\FashionGuide;

public function index(FashionGuide $fg)
{
    $fg->getLoginUrl();
    return view('view', ['loginUrl' => $fg]);
} 
  1. 設定 callback url 取得 authorization code,並且透過 sdk 取得資料
<?php

use \FashionGuide\Oauth2\FashionGuide;
use FashionGuide\Oauth2\Exceptions\RequestException;

public function callback(FashionGuide $fg)
{
    try {
        $user = $fg->get('/member/me');
    } catch (RequestException $e) {
        
    }
}

fashionguide's People

Contributors

flash662 avatar

Watchers

 avatar  avatar

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.