pro_newbie pro_newbie - 1 year ago 171
Java Question

Facebook4j get page likes

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.

String facebookUserName = "Google";

Page pgId = facebook.getPage(facebookUserName);
Page pgL = facebook.getLikedPage(pgId.getId());
System.out.println("Page Likes :" + pgL);
} shows that it have 18,281,664 likes, but when I ran the above code I got null value.

What am I missing here?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download