Instagram Graph API-当用户从个人帐户切换为企业帐户时,获取媒体见解指标

MP *_*oie 6 facebook-graph-api instagram-graph-api

我正在寻找一种使用基于userId的嵌套查询在Instagram Graph API(https://developers.facebook.com/docs/instagram-api/reference/media/insights)中获取Media Insights指标的方法,即使在客户从个人帐户切换到企业帐户。

我使用此嵌套查询来获取我需要的所有数据:(https://graph.facebook.com/v3.2/{userId}?fields=followers_count,media{media_type,caption,timestamp,like_count,insights.metric(reach, impressions)}这部分会导致错误:insights.metric(reach,impressions) -但对于一直是企业帐户的帐户而言,它仍然有效)

但是,由于链接到userId的某些媒体是在用户切换到企业帐户之前发布的,而不是仅返回之后发布的媒体的数据,因此API返回此错误:

{
    "error": {
        "message": "Invalid parameter",
        "type": "OAuthException",
        "code": 100,
        "error_data": {
            "blame_field_specs": [
                [
                    ""
                ]
            ]
        },
        "error_subcode": 2108006,
        "is_transient": false,
        "error_user_title": "Media Posted Before Business Account Conversion",
        "error_user_msg": "The media was posted before the most recent time that the user's account was converted to a business account from a personal account.",
        "fbtrace_id": "Gs85pUz14JC"
    }
}
Run Code Online (Sandbox Code Playgroud)

是否可以通过API知道帐户从“个人”切换到“企业”之前和之后创建了哪种媒体?还是有办法获取帐户切换的日期?

我目前看到的获取所需数据的唯一方法是使用/media边缘并查询每种媒体的见解,直到出现错误为止。然后,我大概会得到所需的日期。但是,由于我们的速率限制为每小时每位用户200个呼叫,因此根本没有优化。

lus*_*chn 2

我遇到了同样的问题并这样解决:

  • 像您一样使用嵌套查询,包括insights.metric
  • 如果出现错误,请再执行一次不带insights.metric- 的调用,至少获取所有其他数据

对于大多数帐户来说,它可以工作,并且不需要额外的 API 调用。对于其余的,我只是无法获得见解,我想我必须忍受它 - 直到 Facebook/IG 解决这个问题。