使用 facebook api 获取朋友生日时出现问题
这是代码,应该检索与今天对应的我朋友的生日。
$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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您的意思是获取与今天相对应的朋友的生日时 - 我假设您想查找您的朋友的生日是否是今天。
1) 首先,您必须获取今天的日期:
2) 其次,使用此日期,我们将运行查询来选择今天生日的所有朋友
3) 接下来检查数据集的大小,如果它为零 - 则有今天没有生日,否则您将循环遍历数据集并打印今天生日的朋友姓名。
如果这不是您要找的 - 请告诉我。
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:
2) Second using this date, we will run a query to select all your friends whose birthday is today
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 this is not what you are looking for - let me know.