如何获取Reddit OAuth阵列用户信息?

时间:2017-10-18 02:09:05

标签: php oauth reddit

这可能是一个简单的问题。我正在使用Pathogen-David身份验证代码的修改。我尝试echo用户帐户名但没有成功。任何帮助都会非常好。

我试过这个

$name = $response->name;// Does not work, returns blank
$name = $response["name"];// Does not work, returns blank

代码

[...rest of code]
else{
$params = array("code" => $_GET["code"], "redirect_uri" => $redirecturi);
$response = $client->getAccessToken($accessTokenUrl, "authorization_code", $params);
$accessTokenResult = $response["result"];
$client->setAccessToken($accessTokenResult["access_token"]);
$client->setAccessTokenType(OAuth2\Client::ACCESS_TOKEN_BEARER);
$response = $client->fetch("https://oauth.reddit.com/api/v1/me");
$name = $response->name;//does not work return blank
$name = $response["name"];//does not work return blank

echo $name;
}

0 个答案:

没有答案