<h1><a href="authorize.php">授权登陆</a></h1> <?php require '../vendor/autoload.php'; use GitHub\GitHub; $gitHub = new GitHub(); echo $gitHub->getAuthorizeUrl('ceshi');
<?php /** * Created by PhpStorm. * User: lee * Date: 15/12/28 * Time: 21:04 */ require '../vendor/autoload.php'; use GitHub\GitHub; session_start(); if (isset($_GET['code'])) { $code = $_GET['code']; $gitHub = new GitHub(); $token = $gitHub->get_access_token($code); if (isset($token['access_token'])) { $access_token = $token['access_token']; $getData = $gitHub->get_user_info($access_token); $info = json_decode($getData, true); //echo json_encode($info); //save userinfo $_SESSION['github'] = $info; echo json_encode($_SESSION['github']); } } //header("location:index.php");
<?php /** * Created by PhpStorm. * User: lee * Date: 15/12/28 * Time: 20:56 */ require '../vendor/autoload.php'; use GitHub\GitHub; $gitHub = new GitHub(); //to redirect $gitHub->authorize('ceshi'); //echo $gitHub->getAuthorizeUrl('ceshi');