首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误消息是(#12) bio字段在版本v2.8及更高版本时不推荐使用

错误消息是(#12) bio字段在版本v2.8及更高版本时不推荐使用
EN

Stack Overflow用户
提问于 2016-10-06 08:14:23
回答 8查看 16.6K关注 0票数 32

我使用了2.0.3版本的spring-social-facebook和Facebook应用程序api v2.8。我打电话给Facebook登录,但回复了这条消息。"(#12)版本v2.8和更高版本都不推荐bio字段“”我如何解决这个问题?“

EN

回答 8

Stack Overflow用户

回答已采纳

发布于 2016-10-06 17:30:22

我也得到了同样的错误,2.0.3.春季社交版的released似乎与8.8FacebookAPI版本(昨天发布)不兼容。从facebook中读取v2.8 (https://developers.facebook.com/docs/apps/changelog):

User用户对象上的bio字段不再可用。如果为某个人设置了bio字段,则该值将被追加到about字段。

我认为我们必须等待春季社交脸书库的新版本。在版本2.0.3中(在接口org.springframework.social.facebook.api.UserOperations)中,PROFILE_FIELDS常量中有"bio“字段,V2.8FacebookAPI版本不支持bio字段)。

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

在此之前:

代码语言:javascript
复制
Connection<Facebook> connection = facebookConnectionFactory.createConnection(accessGrant);
Facebook facebook = connection.getApi();
User userProfile = facebook.userOperations().getUserProfile();//raises the exception caused by the "bio" field.

之后

代码语言:javascript
复制
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);

在这里,您可以使用一个完整的字段列表:

代码语言:javascript
复制
{ "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"}
票数 53
EN

Stack Overflow用户

发布于 2016-12-12 10:39:19

这个问题已经在春季社交facebook的新版本中得到了修正。请在您的pom.xml中添加以下内容

代码语言:javascript
复制
<dependency>
    <groupId>org.springframework.social</groupId>
    <artifactId>spring-social-facebook</artifactId>
    <version>3.0.0.M1</version>
</dependency>

如果您收到此版本不可用的错误,请添加以下内容。

代码语言:javascript
复制
<repositories>
    <repository>
        <id>alfresco-public</id>
        <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
    </repository>
</repositories>
票数 11
EN

Stack Overflow用户

发布于 2016-11-28 07:32:04

代码语言:javascript
复制
package hello;

import  org.springframework.social.connect.ConnectionRepository;
import  org.springframework.social.facebook.api.Facebook;
import  org.springframework.social.facebook.api.PagedList;
import  org.springframework.social.facebook.api.Post;
import  org.springframework.social.facebook.api.User;
import  org.springframework.stereotype.Controller;
import  org.springframework.ui.Model;
import  org.springframework.web.bind.annotation.GetMapping;
import  org.springframework.web.bind.annotation.RequestMapping;

@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","name","birthday","email","location","hometown","gender","first_name","last_name"};
        User user = facebook.fetchObject("me", User.class, fields);
        String name=user.getName();
        String birthday=user.getBirthday();
        String email=user.getEmail();
        String gender=user.getGender();
        String firstname=user.getFirstName();
        String lastname=user.getLastName();
        model.addAttribute("name",name );
        model.addAttribute("birthday",birthday );
        model.addAttribute("email",email );
        model.addAttribute("gender",gender);
        model.addAttribute("firstname",firstname);
        model.addAttribute("lastname",lastname);
        model.addAttribute("facebookProfile", facebook.fetchObject("me", User.class, fields));
        PagedList<Post> feed = facebook.feedOperations().getFeed();
        model.addAttribute("feed", feed);
        return "hello";
    }

}
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39890885

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档