简体   繁体   中英

How can we see users’ information through Facebook Graph API in Android?

I am making a dating app (android) by using Facebook API (You know the similar application that starts with tin…)

Anyways, I registered my application in Facebook developers and I also got approval to use functions that I need through 'Submit Items for Approval'(my Approved Items: email, public_profile, User_photo, User_like, user_work_history, user_education_history )

So, I can log in from my app using my Facebook ID and I can also see users' basic information too.

But! The main problem is that I cannot see photos (except public_profile) even though I was approved for this.

So I really need someone's help. Please help me!

It will be great if you can review the code I used (To use when looking at users' photos)

new Request(Session.getActiveSession(), "/{user-id}/albums", null, HttpMethod.GET, new Request.Callback() {

       @Override
       public void onCompleted(Response response) {                       }                                                  
        }).executeAsync();

You can use facebook graph api for accessing user info

GraphRequest request = GraphRequest.newMeRequest(
    accessToken,
    new GraphRequest.GraphJSONObjectCallback() {
        @Override
        public void onCompleted(
               JSONObject object,
               GraphResponse response) {
            // Application code
        }
    });

To call this method, use below line,

request.executeAsync();

For additional info visit facebook official documentation https://developers.facebook.com/docs/android/graph

Hey Use the following code. It works perfectly for me.

GraphRequest request = GraphRequest.newMeRequest(
        accessToken,
        new GraphRequest.GraphJSONObjectCallback() {
            @Override
            public void onCompleted(
                   JSONObject object,
                   GraphResponse response) {
                // Application code
            }
        });
Bundle parameters = new Bundle();
parameters.putString("fields", "photos.limit(100)");
request.setParameters(parameters);
request.executeAsync();

Try the above code and you will get a jsonobject which can be used to get the image URLs. To know the response you get. Try Graph API explorer. The response format will be the same. https://developers.facebook.com/tools/explorer

if you would like to get the photos of a user try the following code. Please note that you need the user-id to they photos

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

Please refer to https://developers.facebook.com/docs/graph-api/reference/user/photos/

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