Reputation: 779
I'm studying the Facebook4j lib and got stuck on the User authentication. Basically, i want to authorize to find some user and get some data from it like "likes", about and other stuff.
From the start i dont want to go servlets and ect, and to simply use a basic class constuction.
So i'w set up facebook4j lib, the property file for the config builder and:
Facebook facebook = new FacebookFactory().getInstance();
facebook.getOAuthAppAccessToken();
TestUser test = facebook.createTestUser("*************", "bot", "en_EN", "public_profile,user_friends,email,user_about_me,user_actions.books,user_actions.fitness,user_actions.music,user_actions.news,user_actions.video,user_birthday,user_education_history,user_events,user_games_activity,user_hometown,user_likes,user_location,user_managed_groups,user_photos,user_posts,user_relationships,user_relationship_details,user_religion_politics,user_tagged_places,user_videos,user_website,user_work_history,read_custom_friendlists,read_insights,read_audience_network_insights,read_page_mailboxes,manage_pages,publish_pages,publish_actions,rsvp_event,pages_show_list,pages_manage_cta,pages_manage_instant_articles,ads_read,ads_management");
System.out.println("TESTUSER >> "+test);
facebook.setOAuthAccessToken(new AccessToken(test.getAccessToken()));
facebook.getId();
String facebookUserName = "WoodenToaster";
Page pgId = facebook.getPage(facebookUserName);
System.out.println(pgId.getWebsite());
System.out.println("\nabout: "+pgId.getName());
Page pgL = facebook.getLikedPage(pgId.getId());
System.out.println("Page Likes :" + pgL);
but cant find any info on how to even hardcode the users autherization(i did find an example from the main lib's page, which used a redirect, as i see it, to the facebook's auth page, but that's not it).
So the main question is: how to login(or get a user token) using that lib, using only a "main" method of a simple java class?
Upvotes: 0
Views: 170