简体   繁体   中英

Using facebook RestFB API in JAVA

I'm using RestFB facebook API in JAVA. What i need to do is to get: users likes,users friends list, users friends likes.

what is the right flow to do it? Do i need to build an application on facebook that the users will approve and then connect to this application?

I'm very confused with the correct way to implement it :|

thanks!

There's a step by step guide on facebook developers website .

You have to work with an access token that will allow you to use a user's facebook account. Once you've the access, call the appropriate api with user permission to fetch information like basic profile info, friends list, photo, etc.

The RestFB api is open source and is quite good, I haven't had the chance to work with it yet but before using it create a Facebook application and request an OAuth access token. And then proceed as illustrated on the RestFB page .

Something like this:

   FacebookClient facebookClient = new DefaultFacebookClient(YOUR_ACCESS_TOKEN);
    User user = facebookClient.fetchObject("me", User.class); 
    Page page = facebookClient.fetchObject("cocacola", Page.class); 
    out.println("User name: " + user.getName()); 
out.println("Page likes: " + page.getLikes());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM