Facebook Api空异常

时间:2018-08-29 11:16:47

标签: restfb

我正在尝试获取类似数据或注释数据,但始终.getData() 返回null,我不知道为什么

我的代码:

@SuppressWarnings("deprecation")
            FacebookClient fClient = new DefaultFacebookClient("blabla");

            Page page = fClient.fetchObject("me", Page.class);

            System.out.println(page.getName());

            Connection<Post> data = fClient.fetchConnection("me/posts", Post.class);

            for (Post p : data.getData())
            {
                for (LikeItem like : p.getLikes().getData())
                {
                    System.out.println(like.getName());
                }
            }

我做错了什么?

1 个答案:

答案 0 :(得分:0)

您必须在import React, { Component } from "react"; import Link from "next/link"; import { SortDown } from "styled-icons/fa-solid/SortDown.cjs"; import SubMenu from "./SubMenu"; class MobileMenu extends Component { getSlug(url) { const parts = url.split("/"); return parts.length > 2 ? parts[parts.length - 2] : ""; } render() { function uniqId() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } } const menuItems = this.props.menu.map((item, index) => { const slug = this.getSlug(item.url); const uniq = uniqId(); const actualPage = item.object === "category" ? "category" : "page"; if (item.children) { return ( <li> <Link prefetch as={`/${slug}`} href={`/${actualPage}?slug=${slug}&apiRoute=${item.object}`} key={item.ID} remove > <a style={linkStyle}>{item.title}</a> </Link> <SortDown onClick={() => {document.getElementById(uniq).style.display = "flex";}}/> <SubMenu id={uniq} location="mobile" parent={slug} menu={item.children}/> </li> ); } else { return ( <li> <Link prefetch as={`/${slug}`} href={`/${actualPage}?slug=${slug}&apiRoute=${item.object}`} key={item.ID} remove > <a style={linkStyle}>{item.title}</a> </Link> </li> ); } }); } 通话中使用Parameter.with("fields","likes")。 Facebook仅返回您要求的值。在此处查看我们文档中的“简介”部分:https://restfb.com/documentation/#fetching