So right now I am trying to get information from the logged in user through Facebook graph api.
{"id":"10202628284866677","name":"Rohit Tigga","link":"https:\/\/www.facebook.com\/app_scoped_user_id\/10202628284866677\/","picture":{"data":{"is_silhouette":false,"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xta1\/v\/t1.0-1\/p200x200\/10438582_10202555461926149_8285465463541146116_n.jpg?oh=283ec503c6eb051aad077366155c621d&oe=55E6E24B&__gda__=1445616180_3110e5bf89e9f3050fe623b86d47618b"}},"friends":{"data":[{"name":"Arthur Shir","id":"10153237510764181"},{"name":"Kanye East","id":"1454465268197338"}],"paging":{"next":"https:\/\/graph.facebook.com\/v2.3\/10202628284866677\/friends?access_token=CAAWKvUHZCc2sBAHDCZCfL1dHLcrrMoqNxHJSXun5vm1iJQlMxaF43ZCTvIj4Oo4sHeRstTEACDpDz45wLj9FwXBXkoqxPyBQvjcQKY4ZCPgEqhcPdyPb3JepOA1KCADTt2ZBIO8NRX8QKdrlvSWxxgEfSH6SY94nUsLZBRslP8OjJ9r9DYm6kih8GwJ7la0w30KbZAi3AFNOUx1FDU9Y38S&limit=25&offset=25&__after_id=enc_AdB7OPjfCizP7TWz68NToMvADpaegj9bV3w8g22S1dgcGTiHSRUC2xQr2uhJDdQczRtmkKPQS9fzh0Fq7LgWLZAsu"},"summary":{"total_count":1289}}}
I was able to get the id, name, profile_pic_url
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
response.getError();
//Here's what you got
Log.e("JSON:", object.toString());
//Find out how to store all user friends efficiently
try {
user_id=object.getString("id");
name=object.getString("name");
profile=object.getString("link");
profile_pic_url = object.getString("picture");
friends = object.getString("friends");
JSONObject pic_object1= (JSONObject) new JSONTokener(profile_pic_url).nextValue();
JSONObject pic_object2 = pic_object1.getJSONObject("data");
profile_pic_url = (String) pic_object2.get("url");
I am more specifically trying to get the ID of each facebook friend from the logged in user. It is from this portion which I have as a string now.
{"data":[{"name":"Arthur Shir","id":"10153237510764181"},{"name":"Kanye East","id":"1454465268197338"}],"paging":{"next":"https:\/\/graph.facebook.com\/v2.3\/10202628284866677\/friends?access_token=CAAWKvUHZCc2sBAHDCZCfL1dHLcrrMoqNxHJSXun5vm1iJQlMxaF43ZCTvIj4Oo4sHeRstTEACDpDz45wLj9FwXBXkoqxPyBQvjcQKY4ZCPgEqhcPdyPb3JepOA1KCADTt2ZBIO8NRX8QKdrlvSWxxgEfSH6SY94nUsLZBRslP8OjJ9r9DYm6kih8GwJ7la0w30KbZAi3AFNOUx1FDU9Y38S&limit=25&offset=25&__after_id=enc_AdB7OPjfCizP7TWz68NToMvADpaegj9bV3w8g22S1dgcGTiHSRUC2xQr2uhJDdQczRtmkKPQS9fzh0Fq7LgWLZAsu"},"summary":{"total_count":1289}}
I am trying to iterate through the JSON Object and store every id in an array.
But I have been unsuccessful in my attempts.
I am looking at this, yet no luck :/
How to iterate over a JSONObject?
How can I iterate JSONObject to get individual items
How should I go about doing this?