I'm using facebook4j with this configuration setup:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthAppId("*********************")
.setOAuthAppSecret("******************************************")
.setOAuthAccessToken("**************************************************")
.setOAuthPermissions("email,publish_stream,...");
FacebookFactory ff = new FacebookFactory(cb.build());
Facebook facebook = ff.getInstance();
Is there a way to get the Access Token directly with a call frome the code?
ES: Token token = getAccessToken();
Unfortunately,no.The facebook access tokens needs to be generated as follows:
1: Create an application in facebook with your website url
2: Run this link in your browser
3: Visit the following to generate a new SHORT-LIVED (1 hour) access token:
https://www.facebook.com?client_id=[APPID]&client_secret=[APPSECRET]&redirect_uri[http://APPURL]&scope=manage_pages,read_stream&response_type=token
4: Take that short-lived access token and send it here:
https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&client_secret=[APP_SECRET]&grant_type=fb_exchange_token&fb_exchange_token=[EXISTING_ACCESS_TOKEN]
5: Then, either in FB's Graph API Explorer or on your own, visit here:
https://graph.facebook.com/me/accounts?access_token=[TOKEN]
Although, u can write a customized method to do the above in your code.I am working on it and will keep you updated.
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.