简体   繁体   English

如何从新的 facebook 图形 API 获取 Instagram 用户名

[英]How to get instagram username from new facebook graph API

Looking at the new Instagram Graph API - there is no direct way to retrieve username once a user is logged in. Although it says in the official document that a call like看看新的 Instagram Graph API - 一旦用户登录,就没有直接的方法来检索username 。 尽管官方文档中说,调用像

 "https://graph.facebook.com/v3.2/17841405822304914?fields=biography%2Cid%2Cusername%2Cwebsite&access_token=EAACwX..."

should return the following:应该返回以下内容:

{
  "biography": "Dino data crunching app",
  "id": "17841405822304914",
  "username": "metricsaurus",
  "website": "http://www.metricsaurus.com/"
}

This currently returns an error, and looks like there is no such option to get only username of an instagram business user.目前这会返回一个错误,貌似没有这样的选项来获得一个Instagram的商业用户的唯一用户名

在此处输入图片说明

If you are talking about fetching username of an instagram business account which is linked to your facebook page, you can use the below curl如果您正在谈论获取链接到您的 Facebook 页面的 Instagram 商业帐户的用户名,您可以使用以下 curl

curl -i -X GET "https://graph.facebook.com/v3.2/me/accounts?fields=instagram_business_account%7Busername%2Cname%2Cig_id%7D&access_token=<access_token>"

Please replace access_token with your user access token in the above curl.请在上面的 curl 中将 access_token 替换为您的用户访问令牌。

Sample reponse which you will get for the above curl is as below :您将获得上述卷曲的示例响应如下:

{
  "data": [
    {
      "instagram_business_account": {
        "username": "<instagram user name>",
        "name": "<instagram display name>",
        "id": "<corresponding facebook graph id for instagram profile>",
        "ig_id": <instagram profile id>
      },
      "id": "<facebook page id>"
    }
  ],
  "paging": {
    "cursors": {
      "before": "MTc2Njg1MTU2MTI1ODA1",
      "after": "OTg3MzU1NzExNDUwMDg3"
    }
  }
}

I was able to solve this only by using the old api .我只能通过使用旧的 api来解决这个问题。

According to their documentation, although the old API is about to become deprecated, as of now, it is meant for small businesses or personal apps.根据他们的文档,虽然旧的 API 即将被弃用,但截至目前,它适用于小型企业或个人应用程序。 The new Instagram Graph API is "An API for accessing data in large- and medium-sized Instagram Business Accounts"新的Instagram Graph API是“用于访问大中型 Instagram 商业帐户中的数据的 API”

Looks like FB doensn't know it's way around.看起来FB不知道它的方式。

If it helps to someone.. Now its better to do it like this GrapAPI v10.0如果它对某人有帮助..现在最好像这样 GrapAPI v10.0

 FB.api('/' + pageID + '?fields=instagram_business_account{id,name,username}',
     function (response) {
        // TODO: whatever you want
     },
     { access_token: accessToken }
 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM