Reputation: 45
I would like to get name from user id with Graph API, I already have the user id from a SELECT query
https://graph.facebook.com/"+id+"?fields=name
I don't know how to call a http/url query and retrieve the data?
Upvotes: 1
Views: 3229
Reputation: 45
I was able to resolve the issue with this request, I got the solution from this [link]Facebook android sdk how to get the number of likes for a given page
the "id" is from the first query of the actor_id
Bundle params = new Bundle();
params.putString("id", id);
params.putString("fields", "name");
Request request = new Request(session, "search", params, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) { try {
JSONObject res = response.getGraphObject().getInnerJSONObject().getJSONArray("data").getJSONObject(0);
final String name = (String) res.get("name");
Upvotes: 0
Reputation: 20753
Since you are using the Android SDK, you can make the Graph API calls like this-
Bundle params = new Bundle();
params.putString("fields", "name");
final String requestId = {actor-id};
Request request = new Request(session, requestId, params, HttpMethod.GET, new Request.Callback() {
public void onCompleted(Response response) {
GraphObject graphObject = response.getGraphObject();
FacebookRequestError error = response.getError();
if (graphObject != null) {
if (graphObject.getProperty("id") != null) {
String name = (String)graphObject.getProperty("name");
}
}
}
});
Request.executeAndWait(request);
Upvotes: 3