I am using facebook4j-core-2.1.0 and trying to get the page likes. I don't know what I am doing wrong, I am kinda newbie at this.
public static void main(String[] args) throws FacebookException
{
// Generate facebook instance.
Facebook facebook = new FacebookFactory().getInstance();
// access token ...
AccessToken at = new AccessToken(accessTokenString);
// Set access token.
facebook.setOAuthAccessToken(at);
String facebookUserName = "Google";
Page pgId = facebook.getPage(facebookUserName);
Page pgL = facebook.getLikedPage(pgId.getId());
System.out.println("Page Likes :" + pgL);
}
http://www.facebook.com/Google shows that it have 18,281,664 likes, but when I ran the above code I got null value.
What am I missing here?
I think you should try something like this:
String userName = "google";
Page pgId = facebook.getPage(userName);
System.out.println("Page Likes :" + pgId.getLikes());
Hope it helps.