I'm simply trying to get the ID, Name, and profile pic URL of the logged in Facebook User.
I have this:
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {
// Application code
response.getError();
Log.e("JSON:", object.toString());
try {
user_id =object.getJSONObject("").getString("id");
name =object.getJSONObject("").getString("name");
profilepic_url =object.getJSONObject("").getString("link");
} catch (JSONException e) {
e.printStackTrace();
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link");
request.setParameters(parameters);
//Log.e(" About to Graph Call", " ");
request.executeAsync();
//Log.e(" Finished Graph Call", " ");
}
However, all the strings are null. Um....and this is my output once I log the JSONObject...
05-26 20:28:41.426 8248-8248/com.ro.hitup1_0 E/JSON:﹕
{
"id":"10202628284866677",
"name":"Rohit Tigga",
"link":"https:\/\/www.facebook.com\/app_scoped_user_id\/10202628284866677\/"
}
I'm not sure what exactly is the problem. THe jsonobject doesn't have a name. So according to this:
JSONObject - How to get a value ?
or
How to Parse a JSON Object In Android
Shouldn't what I'm doing work? What am I doing wrong and how to fix it?