当我调用org.springframework.social.facebook.api.Facebook.userOperations()。getUserProfile()时我得到以下错误:
org.springframework.social.UncategorizedApiException: (#100) Tried accessing nonexisting field (address) on node type (User)
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleFacebookError(FacebookErrorHandler.java:91) ~[FacebookErrorHandler.class:2.0.2.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookErrorHandler.handleError(FacebookErrorHandler.java:59) ~[FacebookErrorHandler.class:2.0.2.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:641) ~[RestTemplate.class:4.2.3.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:597) ~[RestTemplate.class:4.2.3.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:572) ~[RestTemplate.class:4.2.3.RELEASE]
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:280) ~[RestTemplate.class:4.2.3.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:214) ~[FacebookTemplate.class:2.0.2.RELEASE]
at org.springframework.social.facebook.api.impl.FacebookTemplate.fetchObject(FacebookTemplate.java:209) ~[FacebookTemplate.class:2.0.2.RELEASE]
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:53) ~[UserTemplate.class:2.0.2.RELEASE]
at org.springframework.social.facebook.api.impl.UserTemplate.getUserProfile(UserTemplate.java:49) ~[UserTemplate.class:2.0.2.RELEASE]
我认为这是一个新错误......虽然此代码在此之前没有很好地运用。
请求的个人资料字段位于org.springframework.social.facebook.api.UserOperations
和"地址"字段确实出现在此列表中。
问题也可能是权限,尽管我的印象是我已获得所需的许可。
虽然查看https://developers.facebook.com/docs/graph-api/reference/v2.2/user,但地址未显示在列表中,并且我尝试过的UserTemplate中的所有条目都在那里......
顺便说一下,UserOperations列表是
static final String[] PROFILE_FIELDS = {
"id", "about", "age_range", "address", "bio", "birthday", "context", "cover", "currency", "devices", "education", "email",
"favorite_athletes", "favorite_teams", "first_name", "gender", "hometown", "inspirational_people", "installed", "install_type",
"is_verified", "languages", "last_name", "link", "locale", "location", "meeting_for", "middle_name", "name", "name_format",
"political", "quotes", "payment_pricepoints", "relationship_status", "religion", "security_settings", "significant_other",
"sports", "test_group", "timezone", "third_party_id", "updated_time", "verified", "video_upload_limits", "viewer_can_send_gift",
"website", "work"
};
答案 0 :(得分:3)
在Spring Social Facebook 2.0.3.RELEASE中修复了此问题(例如删除了“地址”字段)。
答案 1 :(得分:0)
对我来说,我无法升级到Facebook 2.0.3 RELEASE所以我改变了我的代码,使用getUserProfile方法专门只询问我需要的东西...(使用pre 2.0.3 getUserProfile包括完整的用户配置文件 - 包括地址)。
我在做:
String adminUser = facebook.userOperations().getUserProfile().getName();
因为我需要的只是用户的名字,所以我将其更改为:
String adminUser = facebook.fetchObject("me", User.class, "name").getName();