会话密钥&访问令牌在Facebook-API [英] Session Key & Access Token in Facebook-API

查看:141
本文介绍了会话密钥&访问令牌在Facebook-API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我解释一次,为什么会话密钥&访问令牌?
我如何抓住这两个?为什么以及何时需要使用它们?当它是一次性,何时不是?



另外,它们之间有什么区别。
请在Java中进行。我是一名新到facebook-API Java开发人员,试图让他的应用程序与Facebook合作。



这是我迄今为止的基本代码:

  FacebookJsonRestClient client = new FacebookJsonRestClient(API_KEY,SECRET); 
HtmlDisplay HD = new HtmlDisplay(http://www.facebook.com/login.php?api_key=1668a3eee255c05918c4234bc4371beb&connect_display=popup&v=1.0&next=http://www.walla.co。 IL&安培; cancel_url = HTTP://www.facebook.com/connect/login_failure.html& fbconnect =真安培; return_session =真安培; session_key_only =真安培; req_perms = user_photos,publish_stream,offline_access);
hd.popUp();
client.auth_getSession(token,true);
System.out.println(client.getCacheSessionKey());

我也试图把



<$ p $在HD中,p> & auth_token = TOKEN

p>

  CLIENT.auth_createToken(); 

无效谢谢

解决方案

会话密钥和访问令牌是两个相互排斥的概念。会话密钥在旧的REST API中使用,访问令牌用于新的OAuth和Graph API。



您使用的java库仅支持旧的REST API,而且相当过时。我建议切换到Graph API java库,如 RestFB



OAuth的授权过程详细描述了 here 。您还会在RestFB页面上找到很多示例。


Can someone please explain to me once and for good what are Session Key & Access Token? How do I catch those two? Why and when do I need to use them? When it is 'one-time' and when it is not?

Also, what are the differences between them. Please do it in Java. I'm a new-to-facebook-API Java developer who's trying to get his application to work with Facebook.

This is my basic code so far:

FacebookJsonRestClient client = new FacebookJsonRestClient(API_KEY, SECRET);
HtmlDisplay HD = new HtmlDisplay("http://www.facebook.com/login.php?api_key=1668a3eee255c05918c4234bc4371beb&connect_display=popup&v=1.0&next=http://www.walla.co.il&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&session_key_only=true&req_perms=user_photos,publish_stream,offline_access");
hd.popUp();
client.auth_getSession(token, true);
System.out.println(client.getCacheSessionKey());

I also tried to put

&auth_token=TOKEN

inside HD and get it with

CLIENT.auth_createToken();

Nothing works. Thanks

解决方案

Session key and access token are two mutually exclusive concepts. Session key was used in old REST API, access token is used in new OAuth and Graph API.

The java library you are using supports only old REST API and pretty outdated. I would suggest switching to Graph API java library, like RestFB.

Authorization process for OAuth is described in details here. You would also find a lot of examples on RestFB page.

这篇关于会话密钥&amp;访问令牌在Facebook-API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆