Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the Facebook profile id using Android and Graph API?

Tags:

android

How do I get a profile id of a Facebook profile to which I have logged in through my Android application?

I have been able to log in to Facebook using the Android and Graph API, but I want to fetch the profile ID of the specific Facebook profile to which I have logged in.

Please help me solve this problem. I am new to Android and the Facebook Graph API. I have searched a lot, but I didn't find any workaround to this.

like image 354
sshah Avatar asked Mar 20 '11 18:03

sshah


People also ask

What data can I get from Facebook Graph API?

The Graph API is the primary way to get data into and out of the Facebook platform. It's an HTTP-based API that apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.

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.


1 Answers

The Facebook graph API lets you make calls that return JSON, which you can parse in Android with a JSONObject.

Facebook fb = new Facebook(API_KEY);
// ... login user here ...
JSONObject me = new JSONObject(fb.request("me"));
String id = me.getString("id");
like image 77
Ankit Avatar answered Oct 04 '22 02:10

Ankit