无法获取用户的年龄,城市,国家/地区,仅能获取显示名称,电子邮件和性别

时间:2018-07-15 06:24:36

标签: hybridauth

我正在使用hybridauth登录我的网站。下面的代码仅显示了我的显示名称,性别和电子邮件,而没有其他显示。但我想获取其他信息,例如年龄,城市,国家。

注意:从我自己的Facebook个人资料中获取信息,而我的api个人资料中包含该信息。我也将所有信息设置为公开。 在hybridauth中,我使用了适用于Facebook的范围,如下所示

 "scope"   => "email,user_gender, user_friends, user_birthday, user_age_range, user_hometown, user_link, user_location",

并通过

获取信息
<?php
/**
 * Build a simple HTML page with multiple providers.
 */

include '../hybridauth/src/autoload.php';
include 'config.php';

use Hybridauth\Hybridauth;

$hybridauth = new Hybridauth($config);

$adapters = $hybridauth->getConnectedAdapters();
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Example 06</title>
</head>
<body>
<h1>Sign in</h1>

<ul>
    <?php foreach ($hybridauth->getProviders() as $name) : ?>
        <?php if (!isset($adapters[$name])) : ?>
            <li>
                <a href="<?php print $config['callback'] . "?provider={$name}"; ?>">
                    Sign in with <strong><?php print $name; ?></strong>
                </a>
            </li>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>

<?php if ($adapters) : ?>
    <h1>You are logged in:</h1>
    <ul>
        <?php foreach ($adapters as $name => $adapter) : ?>
            <li>
                <strong><?php print $adapter->getUserProfile()->displayName." email: ".$adapter->getUserProfile()->email.
                " gender: ".$adapter->getUserProfile()->gender.
                " age: ".$adapter->getUserProfile()->age. " city: ".$adapter->getUserProfile()->city ." country: ".$adapter->getUserProfile()->country." unique id: ".$adapter->getUserProfile()->identifier; ?></strong> from
                <i><?php print $name; ?></i>
                <span>(<a href="<?php print $config['callback'] . "?logout={$name}"; ?>">Log Out</a>)</span>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>
</body>
</html>

,但是上面的代码仅给出显示名称,性别和电子邮件,而没有其他任何显示。

0 个答案:

没有答案