2016-08-15 125 views
-1

我想打印我的OAuth访问令牌用PHP我得到了我的代码和库和 我得到这个错误用PHP:类没有发现

Fatal error: Class 'OAuth2' not found in /home/u490548713/public_html/auth.php on line 13 

我的文件是这样的:

public_html 
    - GrantType 
     - AuthorizationCode.php 
     - ClientCredentials.php 
     - IGrantType.php 
     - Password.php 
     - RefreshToken.php 
    - Client.php 
    - auth.php 

我的代码如下所示:

<?php 
require('Client.php'); 
require('GrantType/IGrantType.php'); 
require('GrantType/AuthorizationCode.php'); 

const CLIENT_ID  = '**'; 
const CLIENT_SECRET =  '***'; 

const REDIRECT_URI   = 'http://*****/****?'; 
const AUTHORIZATION_ENDPOINT = 'https://beam.pro/oauth/authorize'; 
const TOKEN_ENDPOINT   = 'https://beam.pro/api/v1/oauth/token'; 

$client = new OAuth2/Client(CLIENT_ID, CLIENT_SECRET); 
if (!isset($_GET['code'])) 
{ 
$auth_url = $client->getAuthenticationUrl(AUTHORIZATION_ENDPOINT, REDIRECT_URI); 
    header('Location: ' . $auth_url); 
    die('Redirect'); 
} 
else 
{ 
    $params = array('code' => $_GET['code'], 'redirect_uri' => REDIRECT_URI); 
    $response = $client->getAccessToken(TOKEN_ENDPOINT, 'authorization_code',  $params); 
    parse_str($response['result'], $info); 
    echo($info['access_token']); 

} 

?> 

我怎样才能解决这个问题?

+0

修复它通过查找班 '的OAuth2' – 2016-08-15 01:59:11

+0

的PHP文件中包含的类'OAuth2'? – BeetleJuice

+0

包含OAuth2的filé是Client.php – Checkium

回答

1

的OAuth2没有客户没有找到,试试这个new OAuth2\Client(CLIENT_ID, CLIENT_SECRET);