Mr *_*der 2 php facebook facebook-graph-api
我正在寻找通过给定用户对象Id获取所有朋友的生日信息的资源最少的方法.可能使用事件对象,因为朋友的生日在事件中是可见的.
我通过以下方式做了类似的事情:
1)像Awais指出的那样 - 您需要在登录时首先获得用户的扩展许可才能访问他们的生日信息
<fb:login-button perm="user_birthday, friends_birthday"></fb:login-button>
2)有不同的方法,但如果你不使用php sdk,你可以按如下方式获得朋友生日
all_friends_profile = json_decode(file_get_contents('https://api.facebook.com/method/fql.query?query=select+uid,name,birthday_date+from+user+where+uid+in+(select+uid2+from+friend+where+uid1%3Dme())&format=json&access_token=...'));
foreach($all_friends_profile as $profile)
{
echo $profile->name.' birthay='.$profile->birthday_date;
}
只需在上面的代码中替换访问令牌,它就应该遍历所有朋友并打印他们的生日
3)基本上我使用的查询是
select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me())
祝好运
| 归档时间: |
|
| 查看次数: |
7763 次 |
| 最近记录: |