获得朋友生日?
当我使用下面的代码时,它只会为那些与朋友分享他/她生日的人提供生日。然而,即使他们不分享,他们也必须把自己的生日告诉Facebook。我可以获取用户所有朋友的生日吗?我已经获得了 user_birthday
和 friends_birthday
权限。
$friends=json_decode(file_get_contents('https://graph.facebook.com/me/friends?access_token=AAAEHQWIn3oMBADNX0oRCCUujv0Bx8GCKIWQkTIB6KfJxD001x'));
$friends = (array) $friends;
$friends = $friends['data'];
foreach($friends as $key => $friend)
{
$friend = (array) $friend;
$fql = "select name, birthday_date from user where uid=".$friend['id'];
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
print_r ($fqlResult);
}
When I use the code below it gives me birthdays only for those who share his/her birthday with their friends. However, even if they don't share they had to give their birthdays to Facebook. Can I get all of the user's friends' birthdays? I already get user_birthday
and friends_birthday
permissions.
$friends=json_decode(file_get_contents('https://graph.facebook.com/me/friends?access_token=AAAEHQWIn3oMBADNX0oRCCUujv0Bx8GCKIWQkTIB6KfJxD001x'));
$friends = (array) $friends;
$friends = $friends['data'];
foreach($friends as $key => $friend)
{
$friend = (array) $friend;
$fql = "select name, birthday_date from user where uid=".$friend['id'];
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
print_r ($fqlResult);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只能获取用户的朋友与用户共享的生日。所有其他人都是禁区。在某些情况下,这意味着您可能无法获得年份,具体取决于每个人决定分享的内容。
关于您之前的问题(其他人之前链接到过),我强烈建议您在设计应用程序时要非常小心。请确保它遵循服务条款。您可以在 https://developers.facebook.com/policy/ 找到它们。
You can only get birthday's which have been shared with the user by his/her friends. All others are off limits. In some cases, this means that you may not be able to get the year depending on what each person has decided to share.
In relation to your previous question (which someone else linked to earlier), I would strongly recommend being very careful about what you are designing an app to do. And please make sure that it follows the Terms of Service. You can find them at https://developers.facebook.com/policy/.