我按照指南, https://spring.io/guides/gs/accessing-facebook/
并发生错误。
org.springframework.social.UncategorizedApiException :(#12)对于版本v2.8及更高版本,不推荐使用bio字段
这是我的控制器代码。
@Controller
@RequestMapping("/")
public class HelloController {
private Facebook facebook;
private ConnectionRepository connectionRepository;
public HelloController(Facebook facebook, ConnectionRepository connectionRepository) {
this.facebook = facebook;
this.connectionRepository = connectionRepository;
}
@GetMapping
public String helloFacebook(Model model) {
if (connectionRepository.findPrimaryConnection(Facebook.class) == null) {
return "redirect:/connect/facebook";
}
String[] fields = {"id", "email", "first_name"};
User user = facebook.fetchObject("me", User.class, fields);
//System.out.println(user.getFirstName());
model.addAttribute("facebookProfile", facebook.fetchObject("me", User.class, fields));
//PagedList<Post> feed = facebook.feedOperations().getFeed();
//model.addAttribute("feed", feed);
return "home";
}
}
我也看到了Error message is (#12) bio field is deprecated for versions v2.8 and higher
并修改,但似乎无法正常工作。
我评论这一行后也有同样的错误。
User user = facebook.fetchObject("me", User.class, fields);
model.addAttribute("facebookProfile", facebook.fetchObject("me", User.class, fields));