Facebook friends friends birthdays on Android

on Android, what is the easiest way to get friends' one birthday? Or relationship status? Using FQL or requesting it through the Facebook API API for Android?

Thanks.

+4
source share
3 answers
Bundle params = new Bundle(); params.putString("fields","birthday"); JSONObject jObject1 = new JSONObject(authenticatedFacebook.request("me/friends",params)); 

Now, if you type jobject1, you will get a list of all your friends for your birthday.

The response will be in JSON format, which you should get from it.

authenticatedFacebook is an object for Facebook.

For further clarification, you check the link.

 private static final String[] PERMISSIONS = new String[] {"friends_birthday","read_stream", "offline_access"}; 

Make sure you give permission to access your friends ’birthday.

+12
source

What is the easiest way to get friends' birthday? Relationship Status?

Using FQL, we can get the status of relations with the birthdays and friends of the user in one query like this:

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

which can be implemented on Android using the Android Android SDK, for example:

 String query = "SELECT uid, name, birthday_date, relationship_status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())" Bundle params = new Bundle(); params.putString("method", "fql.query"); params.putString("query", query); mAsyncFacebookRunner.request(null, params, new FQLRequestListener()) 

where the FQLRequestListener extends the RequestListener.

The JSON response will look like this:

 { "data": [ { "uid": 1234567890, "name": "John Smith", "birthday_date": "06/16", "relationship_status": "Married" }, { "uid": etc... 

You need

 friends_birthday 

Resolution

+2
source
 try { parameters.putString("format", "json"); parameters.putString(TOKEN, mAccessToken); String url = "https://graph.facebook.com/me/friends?fields=id,name,birthday,location"; String response = Util.openUrl(url, "GET", parameters); JSONObject obj = Util.parseJson(response); Log.i("json Response", obj.toString()); JSONArray array = obj.optJSONArray("data"); if (array != null) { for (int i = 0; i < array.length(); i++) { String name = array.getJSONObject(i).getString("name"); String id = array.getJSONObject(i).getString("id"); Log.i(name,id); } } } 

You need to add permissions

 friends_birthday friends_location 
0
source

Source: https://habr.com/ru/post/1344247/


All Articles