错误消息是 (#12) bio 字段在 v2.8 及更高版本中已弃用

2024-03-19

我使用了 spring-social-facebook 的 2.0.3.RELEASE 版本和 Facebook 应用程序 api v2.8。 我调用 Facebook 登录但返回了此消息。 “(#12) bio 字段在 v2.8 及更高版本中已弃用” 我怎样才能解决这个问题?


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

用户简介 - 用户对象上的简介字段不再可用。如果为某人设置了个人信息字段,则该值现在将附加到“关于”字段。

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

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

BEFORE:

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

AFTER

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"}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

错误消息是 (#12) bio 字段在 v2.8 及更高版本中已弃用 的相关文章

随机推荐