如何使用 Spring Social facebook 从 facebook 获取群组列表?
我已使用 Spring Social facebook api 将我的应用程序与 facebook 连接起来。我尝试使用以下方式获取所有组
FacebookTemplate facebookTemplate = new FacebookTemplate();
List<Group> group = facebookTemplate.fetchConnections("me", "groups", Group.class);
,但它会生成以下错误消息
org.springframework.social.MissingAuthorizationException: Authorization is required for the operation, but the API binding was created without authorization.
org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleFacebookError(FacebookErrorHandler.java:95)
org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleError(FacebookErrorHandler.java:60)
org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213)
org.springframework.social.facebook.api.impl.FacebookTemplate.fetchConnections(FacebookTemplate.java:180)
org.springframework.social.facebook.api.impl.FacebookTemplate.fetchConnections(FacebookTemplate.java:174)
com.horoppa.social.facebook.FacebookFeedController.postUpdate(FacebookFeedController.java:52)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
It may be required to create FacebookTemplate object using AccessToken for authorization.
FacebookTemplate facebookTemplate = new FacebookTemplate(AccessToken);
请帮助我,如何获取 accessToken 以及如何获取所有组。
I have connected my app with facebook using spring social facebook api. I've tried to fetch all groups using following way
FacebookTemplate facebookTemplate = new FacebookTemplate();
List<Group> group = facebookTemplate.fetchConnections("me", "groups", Group.class);
But it generates the following error message
org.springframework.social.MissingAuthorizationException: Authorization is required for the operation, but the API binding was created without authorization.
org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleFacebookError(FacebookErrorHandler.java:95)
org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleError(FacebookErrorHandler.java:60)
org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:486)
org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:443)
org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:213)
org.springframework.social.facebook.api.impl.FacebookTemplate.fetchConnections(FacebookTemplate.java:180)
org.springframework.social.facebook.api.impl.FacebookTemplate.fetchConnections(FacebookTemplate.java:174)
com.horoppa.social.facebook.FacebookFeedController.postUpdate(FacebookFeedController.java:52)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
It may be required to create FacebookTemplate object using AccessToken for authorization.
FacebookTemplate facebookTemplate = new FacebookTemplate(AccessToken);
Please help me, how to get accessToken and how to fetch all groups.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您似乎正在使用 spring-social-showcase。因此,您可以通过以下方式获取当前用户的群组列表
@RequestMapping("/facebook/group")
public class FacebookGroupsController {
}
您还可以发现 SocialConfig.java 中已经为 facebook 创建了
It seems that you are using spring-social-showcase. So, you can fetch group list of current user by following way
@RequestMapping("/facebook/group")
public class FacebookGroupsController {
}
You could also found that the been already created for facebook in SocialConfig.java
您可以尝试下面的代码从 GroupOperations() 获取所有组
You can try below code to get all Groups from GroupOperations()