Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instagram Graph API - Fetch media insights metric when a user switched from personal to business account

I'm looking for a way to fetch Media Insights metrics in Instagram Graph API (https://developers.facebook.com/docs/instagram-api/reference/media/insights) with a nested query based on the userId, even when a client switched from a Personal to a Business account.

I use this nested query to fetch all the data I need : https://graph.facebook.com/v3.2/{userId}?fields=followers_count,media{media_type,caption,timestamp,like_count,insights.metric(reach, impressions)} (this part causes the error: insights.metric(reach, impressions) - it works however for an account that has always been a Business one)

However, because some media linked to the userId were posted before the user switched to a Business account, instead of returning the data only for the media posted after, the API returns this error:

{
    "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"
    }
}

Is there a way to know, thru the API, which media were created before and after the account switch from Personal to Business? Or is there a way to fetch the date on which the account was switched?

The only way I currently see to get the data I need is to use the /media edge and query insights for each media until I get an error. Then I would get approximately the date I need. However, this is not optimized at all since we are rate limited to 200 calls per user per hour.

like image 937
Marie-Pier P-Lavoie Avatar asked Mar 20 '19 19:03

Marie-Pier P-Lavoie


1 Answers

I have the same problem.

For now, I'm Switch between queries (if first have error)

"userId"?fields=id,media.limit(100){insights.metric(reach, impressions)}

"userId"?fields=id,media.limit(100)

I show the user all insights in zero.

I don't know if they're the best alternative, like identify the time of conversion to business and get the post between this range of DateTime

like image 96
Gustavo Chavarria Avatar answered Sep 19 '22 10:09

Gustavo Chavarria