Get Instagram linked pages (Instagram Business Account) for User using Graph API
Asked Answered
R

2

1

These instructions are missing a key element. Unless you know the Page that is linked to the Instagram Business Account, how on Earth are you supposed to get the Id?

https://developers.facebook.com/docs/instagram-api/getting-started/

Is there an API call that will give you all the Instagram Business Accounts the User has authorized the Facebook app to work with?

Something like this would be nice. You could then present a list of choices to the end-user.

Here is a C# code snippet for making the call.

var result = await _facebookClient.GetAsync<dynamic>(
                accessToken, "me/accounts", "fields=id,name,access_token,category,instagram_business_account{id}");

This always returns null. When the User authorizes the app, he/she is able to select a Instagram Business Account, so that piece is working.

I can get all the Facebook pages, but I can't get the ones linked to Instagram Business Accounts.

Thanks in advance! Any help is much appreciated!

Rellia answered 29/6, 2021 at 22:17 Comment(0)
R
1

Something like this works for me.

var result = await _facebookClient.GetAsync<dynamic>(
                accessToken, "me/accounts", "fields=id,name,instagram_business_account{id}");

The key for me was to select the Instagram Account in the auth dialogue as well as the Facebook page the Instagram Business Account is linked to. I was presented with two different windows during auth flow.

What Instagram Business Accounts do you want to use with APPNAME?

  • Select your Instagram user account.

What Pages do you want to use with APPNAME?

  • Select the Page linked to your Instagram Business Account
Rellia answered 30/6, 2021 at 19:15 Comment(0)
C
0

Make a GET request to

https://graph.facebook.com/v19.0/me/businesses/?fields=instagram_accounts{username}

Make sure to add business_management and instagram related permissions for the access token you generate on https://developers.facebook.com/tools/explorer/

Response:

{
  "data": [
    {
      "id": "business_id"
    },
    {
      "instagram_accounts": {
        "data": [
          {
            "username": "insta_username",
            "id": "insta_id"
          }
        ]
      },
      "id": "business id"
    }
  ],
  "paging": {...}
}
Crenel answered 8/3 at 6:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.