简体   繁体   English

通过电话获取访问令牌

[英]Get Access Token with a call

I'm using facebook4j with this configuration setup: 我在此配置设置中使用facebook4j:

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(); ES:令牌令牌= getAccessToken();

Unfortunately,no.The facebook access tokens needs to be generated as follows: 不幸的是,没有。facebook访问令牌需要按以下方式生成:

1: Create an application in facebook with your website url 1:使用您的网站网址在facebook中创建一个应用程序

2: Run this link in your browser 2:在浏览器中运行此链接

3: Visit the following to generate a new SHORT-LIVED (1 hour) access token: 3:访问以下内容,以生成一个新的SHORT-LIVED(1小时)访问令牌:

https://www.facebook.com?client_id=[APPID]&client_secret=[APPSECRET]&redirect_uri[http://APPURL]&scope=manage_pages,read_stream&response_type=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: 4:获取该短暂访问令牌并将其发送到此处:

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] 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: 5:然后,无论是在FB的Graph API Explorer中还是您自己,请访问此处:

https://graph.facebook.com/me/accounts?access_token=[TOKEN] https://graph.facebook.com/me/accounts?access_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. 虽然,您可以在您的代码中编写一个自定义方法来完成上述操作,但我正在努力并会不断为您提供更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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