最简单的方式通过图形API获取所有朋友的生日信息? [英] Easiest way to get birthday info of all friends through graph api?

查看:129
本文介绍了最简单的方式通过图形API获取所有朋友的生日信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找通过给定的用户对象Id获取所有朋友的生日信息的资源最少的方式。

解决方案

我以下列方式做了类似的事情: / p>

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=选择+ UID,名称,birthday_date + +从用户那里+ + + UID在+(选择+ UID2 +从+朋友+其中+ UID1%3Dme())&格式= JSON&的access_token = ...));

foreach($ all_friends_profile as $ profile)
{
echo $ profile-> name。'birthay ='。$ profile-> birthday_date;
}

只需替换上述代码中的访问令牌,它将循环遍历所有的朋友并打印他们的生日< 3)基本上我使用的查询是

 
选择uid,name,birthday_date来自uid的用户(从uid1 = me()的朋友中选择uid2)

祝你好运


I am looking for the least resource intensive way of getting all friends' birthday information by a given user object Id. Probably using Event Object since birthdays of friends are visible inside events.

解决方案

I've done something similar in the following way:

1) Like Awais pointed out - you need to first get the extended permission from the user at the time of login to access their birthday information

<fb:login-button perm="user_birthday, friends_birthday"></fb:login-button>

2) There are different ways of doing this, but if you are not using php sdk, you can get the friends birthday as follows

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;                  
}

Just replace the access token in the above code and it should loop through all your friends and print their birthdays

3) Basically the query I have used is

select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me())

Good luck

这篇关于最简单的方式通过图形API获取所有朋友的生日信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆