Skip to main content
 首页 » 编程设计

spring-social-facebook之错误消息是 (#12) 版本 v2.8 及更高版本不推荐使用 bio 字段

2024年09月07日24yxwkf

我使用了 spring-social-facebook 和 Facebook app api v2.8 的 2.0.3.RELEASE 版本。
我调用 Facebook 登录,但返回了这条消息。
“(#12) 版本 v2.8 及更高版本不推荐使用 bio 字段”
我怎样才能解决这个问题?

请您参考如下方法:

我得到了同样的错误,spring-social-facebook 的 2.0.3.RELEASE 似乎与 v2.8 Facebook API 版本(昨天发布)不兼容。从 facebook 更新日志中读取 v2.8 (https://developers.facebook.com/docs/apps/changelog):

用户履历 - 用户对象上的履历字段不再可用。如果为某人设置了 bio 字段,则该值现在将附加到 about 字段。

我认为我们必须等待 spring-social-facebook 库的新版本。在 2.0.3 版中(在接口(interface) org.springframework.social.facebook.api.UserOperations 中),PROFILE_FIELDS 常量中有“bio”字段,v2.8 facebook API 版本不支持它。

更新:我在我的案例中找到了一种解决方法:

前:

Connection<Facebook> connection = facebookConnectionFactory.createConnection(accessGrant); 
Facebook facebook = connection.getApi(); 
User userProfile = facebook.userOperations().getUserProfile();//raises the exception caused by the "bio" field. 



Connection<Facebook> connection = facebookConnectionFactory.createConnection(accessGrant); 
Facebook facebook = connection.getApi(); 
String [] fields = { "id", "email",  "first_name", "last_name" }; 
User userProfile = facebook.fetchObject("me", User.class, fields); 

这是您可以使用的字段的完整列表:
{ "id", "about", "age_range", "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"}