Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Facebook get all profile information

How i can fetch all of user profile information from facebook (like first name, last name, email etc.)

I have downloaded the FB SDK but there is no example for getting the profile info.

like image 769
Zahid Naqvi Avatar asked Apr 01 '11 12:04

Zahid Naqvi


People also ask

How can I see my full Facebook details?

If you want to download a copy of your information from Facebook, you can use the Download Your Information tool. Tap in the top right of Facebook. Scroll down and tap Settings. Scroll down to Your Facebook Information and tap Download Your Information.

How do I find Facebook user data?

You can get user data by using the Facebook Graph API if the user has given their permission to share their data and your app has the appropriate permissions to receive this data. This topic shows you how to make a single request for data and how to have a batch of requests in a single request.

Is there a Facebook API?

What is the Facebook API? The Facebook Graph API is an HTTP-based API that allows developers to extract data and functionality from the Facebook platform. Applications can use this API to programmatically query data, post in pages and groups, and manage ads, among other tasks.

Is Facebook SDK free?

The Graph API is free to use, for all applicable use cases. Rate Limiting applies though, > developers.facebook.com/docs/graph-api/advanced/rate-limiting There is no way to “pay” or > otherwise get those limits raised for normal 3rd party apps.


2 Answers

There's an example in the folder facebook-android-sdk/examples/simple. It shows how to make an async request for the basic data of the user. You'll be able to find these data.

Cheers

like image 187
Xavier Balloy Avatar answered Sep 18 '22 20:09

Xavier Balloy


Here is a quickest way that worked for me

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;

import android.widget.Toast;

import com.facebook.Request;
import com.facebook.Request.GraphUserCallback;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.Session.StatusCallback;
import com.facebook.SessionState;
import com.facebook.model.GraphUser;
import com.x.y.android.R;

public class FBConnect extends FragmentActivity {
    private static final String TAG = "FacebookConnect";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.facebook_connect);


    if (Session.getActiveSession() == null
            || Session.getActiveSession().isClosed()) {
        Session.openActiveSession(this, true, new StatusCallback() {

            @Override
            public void call(Session session, SessionState state,
                    Exception exception) {
                System.out.println("State= " + state);

                if (session.isOpened()) {
                    System.out.println("Token=" + session.getAccessToken());
                    Request.executeMeRequestAsync(session,
                            new GraphUserCallback() {
                                @Override
                                public void onCompleted(GraphUser user,
                                        Response response) {
                                    if (user != null) {
                                        System.out.println("User=" + user);

                                    }
                                    if (response != null) {
                                        System.out.println("Response="
                                                + response);
                                        Toast.makeText(FBConnect.this,
                                                response.toString(),
                                                Toast.LENGTH_LONG).show();
                                    }
                                }
                            });
                }
                if (exception != null) {
                    System.out.println("Some thing bad happened!");
                    exception.printStackTrace();
                }
            }
        });
    }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Session.getActiveSession().onActivityResult(this, requestCode,
            resultCode, data);
    }

}
like image 40
Thamme Gowda Avatar answered Sep 18 '22 20:09

Thamme Gowda