How to execute graphics-api Facebook Android SDK

I can run this in facebook API to get user id, username, recent status and profile picture,

/8794851923?fields=id,name,statuses,picture 

how to do it in android using Facebook-SDK and get the result?

I tried this one , but it is out of date.

Thanks,

+4
source share
2 answers

After watching the SDK on facebook, I got the following:

  Bundle params = new Bundle(); params.putString("fields", "id,name,statuses"); final String requestId = "154727011315956"; 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(error!=null){ Log.e("Error", error.getErrorMessage()); } } }); Request.executeAndWait(request); 
+5
source

The Graph API is the main way to get data to and from Facebook's social graph. This is a low-level HTTP interface that you can use to request data, publish new stories, upload photos and other tasks that the application may require. This guide will teach you how to complete all these steps in the graphical API.

 /* make the API call */ new GraphRequest( AccessToken.getCurrentAccessToken(), "/me", null, HttpMethod.GET, new GraphRequest.Callback() { public void onCompleted(GraphResponse response) { /* handle the result */ System.out.println("Response::" + String.valueOf(response.getJSONObject())); } } ).executeAsync(); 

Here

AccessToken.getCurrentAccessToken () → User Access Token

/ me → Information about your own developer profile

here the identifier / username / page is also used to get this information for example: / joshuatreemusicfestival / posts /

null → here the parameters of the actual receipt of the type of user / page information, such as:

 Bundle param = new Bundle(); param.putString("fields", "message,created_time,id,full_picture,status_type,source,comments.summary(true),likes.summary(true)"); 

param replace null

HttpMethod.GET → The request method [GET, POST, DELETE]

Finally onCompleted () call and get the answer you want ... !!!

For reference

0
source

All Articles