-1

在 FB Graph API 资源管理器中,获取 business_discovery 数据的调用使用任何用户的 Instagram id(在这种情况下是我自己的帐户),并使用“用户名”来指示想要从中获取一些公共信息的第 3 方帐户.

例如,我们想要获取 instagram 页面motorolaus的名称、followers_count、media_count 等公共数据 - Graph Explorer 调用将类似于:

GET /v3.2/?fields=name,username,business_discovery.username(motorolaus){name,followers_count , media_count }

但是 restFB 调用 IgUser.getBusinessDiscovery() 不像 Graph API explorer 那样使用用户名。那么我怎样才能获得 Instagram 页面的公共信息(这不是我自己的)?谢谢

4

2 回答 2

2

借助有用的 restFB 人员的提示,我现在可以回答我自己的问题,以防其他人有同样的问题:

基本上,我们想要公共数据的 instagram 页面的名称必须在获取期间传入。下面的代码说明了。假设我们想从“motorolaus”Instagram 页面获取公共信息。

// first you need to define the fields you want to fetch.
// For example, let's say we want the name, username,
// number of followers, number of posts(media) and the profile pic:

String businessDiscoveryFields = "business_discovery.username(motorolaus){name,username,followers_count,media_count,profile_picture_url}";

// Then we fetch the restFB IgUser object, using as id (1st parameter)
// the id of your Instagram business page, for which you got the
// access token. This is a string, formed by digits only.

IgUser igMyUser = facebookClient.fetchObject(my_instagram_bizpage_id, IgUser.class,Parameter.with("fields", businessDiscoveryFields));

// now we get the IgUser object for the page we want (motorolaus in
// this example), and from there we get the public data
IgUser igBizUser = igMyUser.getBusinessDiscovery();

System.out.printf("Instagram page %s (%s)\n", igBizUser.getName(), igBizUser.getUsername());
System.out.printf("   num followers: %s\n", igBizUser.getFollowersCount());
于 2018-12-06T12:55:17.460 回答
0

您正在寻找的电话如下所示:

IgUser user = fbClient.fetchObject("/", 
        IgUser.class, 
        Parameter.with("fields","name,username,business_discovery.username(motorolaus) 
            {name,followers_count, media_count}");

之后,IgUser对象 ( user) 将填充所需的值。我假设您已经有一个 facebook 客户端 ( fbClient)。

于 2018-12-06T12:28:17.923 回答