How to display the posts of a facebook page?

0

I want to display the posts from a Facebook FanPage in an app.

I've been researching and some people have helped me and said to use the facebook API. Well, I'm using it, but since facebook does not help anyone, I come here to ask for your help.

I'm using the code below, but from here how do I make the posts appear?

PS: I already have the access token but I do not know how to use it.

new GraphRequest(
        AccessToken.getCurrentAccessToken(),
        "/251217778341818/feed",
        null,
        HttpMethod.GET,
        new GraphRequest.Callback() {
            @Override
            public void onCompleted(GraphResponse graphResponse) {
                try {
                    String titulo = graphResponse.getJSONObject().getString("");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }
).executeAsync();
    
asked by anonymous 02.05.2015 / 01:34

1 answer

1

Facebook provides an API for you to access this information.

In your case, to list the feed for a fan page, there is the service /page/feed in Graph API . In this case everything in the feed is listed, including status updates and posts from other users.

View the variance /page/posts to only have posts published per page.

Removing from the reference documentation, an example in javascript would be:

FB.api(
    "/{page-id}/feed",
    function (response) {
      if (response && !response.error) {
        // faça seu trabalho aqui
      }
    }
);

And this one in the android SDK:

new Request(
    session,
    "/{page-id}/feed",
    null,
    HttpMethod.GET,
    new Request.Callback() {
        public void onCompleted(Response response) {
            // faça seu trabalho aqui
        }
    }
).executeAsync();

At reference documentation you can find all the information you need to use the API, including how to get the {page-id} .

How did you quote and #, see the SDKs com / docs / javascript "> javascript and android

    
02.05.2015 / 21:41