如何使用RestFB IgUser getBusinessDiscovery()? [英] How do i use RestFB IgUser getBusinessDiscovery()?

查看:105
本文介绍了如何使用RestFB IgUser getBusinessDiscovery()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在FB Graph API资源管理器中,获取business_discovery数据的调用使用任何用户的Instagram ID(在本例中为我自己的帐户),并使用用户名"指示要从中获取的第三方帐户一些公共信息.

In the FB Graph API explorer the call to get business_discovery data uses the Instagram id for any user (in this case my own account) and uses a "username" to indicate the 3rd-party account from which one would like to get some public information.

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

Say for example, we want to get public data like name,followers_count,media_count for the instagram page motorolaus - the Graph Explorer the call would be something like:

GET/v3.2/?fields=名称,用户名,business_discovery.username( motorolaus ){名称,关注者数,媒体数}

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

但是restFB调用IgUser.getBusinessDiscovery()不会使用Graph API Explorer这样的用户名. 那么我如何获得instagram页面的公开信息(这不是我自己的)? 谢谢

But the restFB call IgUser.getBusinessDiscovery() does not take a username like the Graph API explorer. So how can i get the public info for an instagram page (which is NOT my own)? Thanks

推荐答案

在有帮助的restFB员工的提示下,我可以回答我自己的问题,以防其他人有相同的问题:

With hints from the helpful restFB folks, I can now answer my own question, in case others have the same question:

基本上,我们要获取公开数据的instagram页面名称必须在获取过程中传递. 以下代码进行了说明.假设我们要从"motorolaus" Instagram页面获取公共信息.

Basically, the name of the instagram page, for which, we want public data, has to be passed in during the fetch. The following code illustrates. Suppose we want to get public info from the "motorolaus" Instagram page.

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

这篇关于如何使用RestFB IgUser getBusinessDiscovery()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆