我想用php打印我的oauth访问令牌我得到了我的代码和库 我用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']);
}
?>
我该如何解决?