Twitch API#而不是?在URL中


Twitch API # instead of ? in URL

代码:

if (isset($_GET['access_token'])) {
$_SESSION['oauth'] = $_GET['access_token'];
$usernameResult = file_get_contents("https://api.twitch.tv/kraken?oauth_token=" . $_SESSION['oauth']);
$json_decoded_usernameResult = json_decode($usernameResult, true);
echo $_SESSION['username'] = $json_decoded_usernameResult['token']['user_name'];
} else {
header('Location: https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id={clientID}&redirect_uri=http://127.0.0.1/thebot/oauth');
}

结果是我的URL变成了"http://127.0.0.1/thebot/oauth#access_token={AccessToken}&scope=".不知怎么的"?"被替换为"#"。有人看到我的代码中有错误吗?或者知道一个变通方法,这样我就可以把它关掉吗?

看起来您正在期待授权代码流,但正在访问隐式授予流。我建议看看这里的区别。