Facebook公司的openID认证



我一直在我的网站上实现谷歌/Facebook认证系统。我使用它们各自的服务对用户进行身份验证,然后使用结果在我这端实例化会话。Google的运行没有问题,但是Facebook的遇到了问题。

我可以验证用户没有问题,但当试图验证公司或其他Facebook页面类型时,它失败了。

例如,使用GraphAPI,我能够检索他们的一个示例https://graph.facebook.com/btaylor中显示的值并正确地存储它。

但是当我尝试使用相同的系统来验证公司(例如https://graph.facebook.com/nike)时,它失败了,因为对象不是GraphAPI返回的用户结果的一部分。

设置调用的正常内容:

$FBcookie = get_facebook_cookie(YOUR_APP_ID, YOUR_APP_SECRET);
$user = json_decode(file_get_contents_curl('https://graph.facebook.com/me?access_token='.$FBcookie['access_token']));

当存储结果时,它作为用户工作得很好:

$_Fname =$user->first_name;
$_Lname =$user->last_name;

但是试图访问上面Nike示例中所看到的预期属性时,没有返回任何内容。

我甚至尝试回显对象,看看那里有什么:

print('<pre>');
print_r($user);
print('</pre>');

对于用户,我可以看到所有内容,对于非用户(公司、事件或其他页面类型),我什么也看不到。

问题是,有没有人看到我们可能需要通过GraphAPI查询的其他对象?Facebook开发者页面到处都是,没有真正的简明教程。

facebook上的公司/页面信息如下:

$user->id;
$user->name;
$user->picture;
$user->link;
$user->likes;
$user->category;
$user->website;
$user->username;
$user->description;
$user->public_transit;

所以$user->first_name;$user->last_name;不存在

你可以试试这样做:

if(empty($user->first_name)&&empty($user->last_name)){
//probably company set $user->username;
}

最新更新