简体   繁体   中英

what is the difference between “Request.newMeRequest” and “new http Request(”

I want to get some FB data from my android app.

I see there are two ways of doing this:

A)

new Request(session,"/me/interests", null, HttpMethod.GET,
                new Request.Callback() {
                    public void onCompleted(Response response) {
                        /* handle the result */
                    }
                }
            ).executeAsync();

B)

Request.newMeRequest(session, new Request.GraphUserCallback() {
            @Override
            public void onCompleted(GraphUser user, Response response) {

is one of them deprecated?

how do i ask for specific node\\edge (eg "/me/interests") in the second signature?

Does it gives me all the node ready made as long as I asked for the proper permissions?

1) As specified in the docs ( https://developers.facebook.com/docs/reference/android/current/class/Request/ ), none of them is deprecated.

2) You can't ask for a specific node/edge, because it is already configured to retrieve a users profile.

3) You get a GraphUser and a Response as a return (in onComplete ).

Most likely, newMeRequest will call new Request internally.

Request.newMeRequest is simply a wrapper around new Request(session, "/me"). It's a convenience method.

If you want to ask for anything else, you need to construct it yourself, probably using the newGraphPathRequest method - https://developers.facebook.com/docs/reference/android/current/class/Request/#newGraphPathRequest

So for the "me/interests" example above, you would do something like:

Request.newGraphPathRequest(session, "me/interests", new Request.Callback() {...})
  .executeAsync();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM