gpt4 book ai didi

java - 如何使用 RestFB IgUser getBusinessDiscovery()?

转载 作者:行者123 更新时间:2023-12-02 01:46:26 28 4
gpt4 key购买 nike

在FB Graph API资源管理器中,获取business_discovery数据的调用使用任何用户的Instagram ID(在本例中是我自己的帐户),并使用“用户名”来指示想要从中获取的第3方帐户一些公开信息。

举例来说,我们想要获取 Instagram 页面 motorolaus 的公共(public)数据,例如 name、followers_count、media_count - Graph Explorer,调用将类似于:

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

但是,restFB 调用 IgUser.getBusinessDiscovery() 不会像 Graph API 浏览器那样采用用户名。那么我如何获取 Instagram 页面的公共(public)信息(这不是我自己的)?谢谢

最佳答案

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

基本上,我们需要在获取公共(public)数据时传入 Instagram 页面的名称。下面的代码说明了这一点。假设我们想从“motorolaus”Instagram 页面获取公共(public)信息。

// 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());

关于java - 如何使用 RestFB IgUser getBusinessDiscovery()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53637555/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com