我正在编写一个应用程序,我将在接下来的30天内获取那些生日的朋友列表,我也能够得到它,但我在列表中遇到了一个小问题。
喜欢:我在接下来的30天里有4个朋友的生日,所以我得到即将到来的facebook朋友生日的名单,但没有获得生日就是今天的朋友的名字
我想我在查询中遗漏了一些东西。
代码:
Calendar cal = Calendar.getInstance();
Date today = cal.getTime();
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
String today_formatted = formatter.format(today);
cal.add(Calendar.DATE, 30); //set number of days
String today_plus30_formatted = formatter.format(cal.getTime());
String query = "select name, birthday, uid, pic_square FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND birthday_date > '" + today_formatted + "'AND birthday_date < '" + today_plus30_formatted + "'ORDER BY birthday_date ASC";
如果我将使用以下查询,那么我没有得到我的朋友列表:
String query = "select name, birthday, uid, pic_square FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1 = me()) AND birthday_date != 'null' AND birthday_date > = '" + today_formatted + "'AND birthday_date < = '" + today_plus30_formatted + "'ORDER BY birthday_date ASC";
答案 0 :(得分:1)
Rakesh你做了一切,这也是正确的:
你只需要删除:“/ yyyy”
替换下面的行,你完成了:
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd");
答案 1 :(得分:0)
您确定允许访问朋友的生日日期
private static final String[] PERMISSIONS =
new String[] {"friends_birthday","read_stream", "offline_access"};
http://www.androidhive.info/2012/03/android-facebook-connect-tutorial/
这是简单的例子