使用 facebook api 获取朋友生日时出现问题

发布于 2024-10-16 11:41:01 字数 775 浏览 1 评论 0原文

这是代码,应该检索与今天对应的我朋友的生日。

$friends = $facebook->api('me/friends');
$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 : $current_date<br />";

$data = $facebook->api(array('method'=>'fql.query','req_perms' => 'friends_birthday','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 />";
 }

在我的页面中,我还有另一个脚本可以在这个脚本之上检索用户朋友并且它可以正常工作, 此片段显示的结果是搜索和空白!!!!

请帮忙 谢谢

here is the code , that supposed to retreive the birthday of my friends corresponding to today .

$friends = $facebook->api('me/friends');
$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 : $current_date<br />";

$data = $facebook->api(array('method'=>'fql.query','req_perms' => 'friends_birthday','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 />";
 }

in my page i have another script to retrive user friends too above this one and its working properly ,
the result shown with this snippet issearching and WHITE SPACE !!!!

please help
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妖妓 2024-10-23 11:41:01

当您的意思是获取与今天相对应的朋友的生日时 - 我假设您想查找您的朋友的生日是否是今天。

1) 首先,您必须获取今天的日期:

$today = date('m\/d');

2) 其次,使用此日期,我们将运行查询来选择今天生日的所有朋友

$data = $facebook->api(array(
    'method'    =>'fql.query',
    'req_perms' => 'friends_birthday',
    'query'     => "select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me()) and strpos(birthday_date,$today)>=0 ") );

3) 接下来检查数据集的大小,如果它为零 - 则有今天没有生日,否则您将循环遍历数据集并打印今天生日的朋友姓名。

if(count($data)==0)
{
   echo 'No Friends Birthdays today';
}
else
{
    echo 'Friends whose birthday is today';
    foreach($data as $today_bday) {
        echo $today_bday['name'];
    }
}

如果这不是您要找的 - 请告诉我。

When you mean getting friends' birthdays corresponding to today - I'm assuming you want to find if any of your friends birthday is today or not.

1) First thing, you have to get today's date:

$today = date('m\/d');

2) Second using this date, we will run a query to select all your friends whose birthday is today

$data = $facebook->api(array(
    'method'    =>'fql.query',
    'req_perms' => 'friends_birthday',
    'query'     => "select uid,name,birthday_date from user where uid in (select uid2 from friend where uid1=me()) and strpos(birthday_date,$today)>=0 ") );

3) Next you check the size of the data set, if it's ZERO - there are no birthdays today, else you loop through the dataset and print the friends name whose birthday is today.

if(count($data)==0)
{
   echo 'No Friends Birthdays today';
}
else
{
    echo 'Friends whose birthday is today';
    foreach($data as $today_bday) {
        echo $today_bday['name'];
    }
}

If this is not what you are looking for - let me know.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文