0

I need to make a simple query SELECT url FROM url_like WHERE user_id={friendId} in my Facebook app that I build with help of Spring Social. To do this I use authentication code provided by this library. The authentication works fine. But the query mentioned above returns an empty array. I would like to emphasizes that all the needed permissions are given (user_likes and friend_likes). However similar access token given to me by facebook graph explorer works perfectly.

Access token debugger from Facebook says that both tokens are valid and have needed permissions. The only difference in the duration of token validity: my app gives token that expires in 2 months and Graph Api gives for an hour.

What is the reason of this strange behaviour? Why token given by my app with needed permissions is unable to make this query. How to fix this issue? Thank you in advance.

UPDATE Ok, it seems that Facebook gives access token for application that is different from access token of a user. So now the question is how to get user's access token with Spring Social Facebook?

4

1 回答 1

0

您需要向特定提供商的 spring social ConnectController 提交发布请求,例如http://www.yourdomain:8089/connect/facebook。然后 Spring social 会将用户重定向到 facebook 授权页面,用户将在该页面授予您的应用程序所要求的权限并将代码发送回您的服务器。Spring social 然后将该代码交换为访问令牌。您需要为该用户建立连接,以便能够代表他/她对 FB 执行请求。这是一个可能有帮助的文档页面http://static.springsource.org/spring-social/docs/1.0.0.M2/reference/html/connecting.html

于 2013-07-28T17:59:21.390 回答