Show friends

However, I get the Facebook Friends List in form from January to December in ascending order, see image below:

But now I want to show Facebook Friends List in the form of upcoming Like birthdays:

Top Reviews

I use the below query to retrieve a list of friends:

Log.d(LOG_TAG, "requestFriends(" + ")"); Date date = new Date(); String current_date = null; SimpleDateFormat dateFormatter = new SimpleDateFormat("MM-dd-yyyy"); current_date = dateFormatter.format(date); System.out.println("Current Date is:- " + current_date); String query = "select name, birthday, uid, pic_square from user where uid in (select uid2 from friend where uid1=me()) and birthday_date>= " + current_date + " order by birthday_date"; 

Please tell me which query should I use to get a list in the form of upcoming B'days

+4
source share
1 answer

This request will capture the list of all friends in the registered user account:

 SELECT uid, name, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY birthday_date ASC 

Trap of this - you will need to check if the user has entered his birthday in his Facebook accounts.

Best query (at least I think is better):

 SELECT uid, name, birthday_date FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me()) AND birthday_date >= '02/01' AND birthday_date <= '07/01' ORDER BY birthday_date ASC 

This list only receives a list of users who have filled in their birthday on their Facebook accounts. And with ORDER BY birthday_date they will always be with the upcoming birthday at the top, right up to the last in the result set.

Trap this, and feel free to test it, I never got whole years on my birthday using the second query. SO in my application, I call after 6 months of data at a time. It has always been accurate and pretty much hack.

I suspect that the second request will meet your goal, given that you need to show your upcoming birthday at the top of the list. To always get the current date and month to get the exact result, use this example (and a simple Google search or a SO search will give you more) to get the current date and month:

http://www.asbhtechsolutions.com/android-tutorials/android-get-current-date-and-time

Then concatenate a String and pass this instance as a request.

NOTE. . The month and date used in the request must be double digits at all times .

+1
source

All Articles