从Facebook个人资料中获取朋友的生日 [英] Fetching friends' birthdays from facebook profile

查看:119
本文介绍了从Facebook个人资料中获取朋友的生日的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从他们的Facebook个人资料(提供他们的Facebook凭据)获取用户及其朋友在我的网站上的生日。

I want to fetch 'birthdays' of users, and their friends on my website, from their facebook profiles (with their facebook credentials supplied).

他们的在Facebook API / Connect中的功能,我可以用来从Facebook上获取这些细节在本地Facebook应用程序使用Facebook API。

Is their a feature in Facebook API/Connect that I can use to fetch these details from facebook as possible on Native Facebook Apps using Facebook API.

我想将此数据存储在我的数据库在此之前,用户将被要求获得他们的Facebook凭据和同意。

I want to store this data in my DB, and users will be asked for their facebook credentials and consent before this is done.

推荐答案

所以最近我想检查我的朋友看看他们当中有没有生日。使用FQL这是非常简单的,我鼓励您更多地探索FQL,因为它会产生比Pierre亲切提供的更有效的解决方案。以下是一小段代码:

So recently I wanted to check my friends to see if any of them had their birthday for the current day. Using FQL this is super easy and I encourage you to explore FQL more because it will yield a more efficient solution than, say, what Pierre kindly offered. Here is a small snippet of the code:

$friends = $facebook->api_client->friends_get();
$uids = "";

foreach($friends as $f) {
  $uids .= "uid=$f OR ";
}

$query_uids = substr($uids,0,strlen($query_uids)-4);

date_default_timezone_set('UTC');
$current_date = date("m/d");
echo "<br />Searching for birthdays for the given month/day: $current_date<br />";

$data = $facebook->api_client->fql_query( "SELECT name, uid FROM user WHERE ( ($query_uids) AND strpos(birthday_date,'$current_date') >= 0 )" );

if(count($data) > 0) {
  foreach($data as $d) {
    print_r($d);
  }
} else {
 echo "<br />No Birthdays Today<br />";
 }

这篇关于从Facebook个人资料中获取朋友的生日的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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