Reputation: 328
I need to get my fan page data i.e number of likes, recent liked users; to my android application.
With out log in to facebook the application user should be abel to use the app.
I tried Facebook SDK for Android, but didn't find a way to access page data. It seems that a user should be logged in to facebook in order to get data.
When I check on this, the number of likes can be accessed. But how to do this for a given page without asking the user to log in?
any idea on this? Thank you in advance.
Upvotes: 1
Views: 3188
Reputation: 2185
after installing Facebook SDK, try this
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/{page-id}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
Upvotes: 0
Reputation: 6318
some page info can be accessed without user login, such as number of likes; for details, you can check them out here.
and here is how you can get them:
private Facebook mFacebook = new Facebook("xxxxxx");
private AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(mFacebook);
mAsyncRunner.request("yourPage", new RequestListener() {
@Override
public void onComplete(String response, Object state) {
Log.d(LOG_TAG, response); // page info JSONObject
}
@Override
public void onIOException(IOException e, Object state) { }
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) { }
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) { }
@Override
public void onFacebookError(FacebookError e, Object state) { }
});
P.S. Graph API Explorer is a great tool for playing with the Graph API.
Upvotes: 0
Reputation: 11107
With out log in to facebook the application user should be abel to use the app.
Without Login to facebook you can't access Facebook Details
Use below this Snippet to get Pages information to which user subscribed :
Bundle likes_params = new Bundle();
likes_params.putString("fields", "id,name,picture");
jObj_friends_likes = new JSONObject(authenticatedFacebook.request("me/likes",likes_params));
where authenticatedFacebook is your Facebook instance & fields you can add whatever you need
Upvotes: 1