我正在尝试传递我登录时在 URL 中收到的 access_token,但在验证并获取访问令牌后,我无法通过“$_GET”调用它。我还在任何地方得到空数组(在 if 语句中,在最后,在代码的开头)。
<?php
define("client_id",'XXXXXX');
define("response_type",'token');
define("scope", 'activity heartrate weight');
define("expires_in", '86400');
echo $_GET;
print_r($_GET['access_token']);
var_dump($_GET);
if($_GET['access_token']){
echo 'success';
} else {
?>
<!DOCTYPE html>
<html>
<head>
<title>FITBIT API</title>
</head>
<body>
<a href="https://www.fitbit.com/oauth2/authorize?response_type=<?php echo response_type; ?>&client_id=<?php echo client_id; ?>&scope=<?php echo scope; ?>&expires_in=<?php echo expires_in; ?>">LOGIN INTO FITBIT</a>
</body>
</html>
<?php
}
?>
Fitbit 在我登录 Fitbit 后在 URL 中回复此链接,这让我感到困惑,我在那里看到 access_token 但 $_GET 不会“获取它”:
http://www.xxx.xxx/fitbit.php?#scope=weight+heartrate+activity&user_id=23942H&token_type=Bearer&expires_in=74915&access_token=eyJhbGciOizIUzI1NiJ9.eyJleHAiOjE0NDc3MzYzOTAsInNjb3BlcyI6InJ3ZWkgcmhyIHJhY3QiLzJzdzIiOiIyMzk0MkgiLCJhdWQiOiIyMjlTzloiLCJpc3MiOiJGaXRiaXQiLCJ0eXAiOiJhY2Nlc3NfdG9rZW4iLCJpYXQiOjE0NDc2NzE0NzV9.YDy6fiyZ7iZ6wKJ2tYTI_NV8MHL5k4ymLcRGHmoPO0k