You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Facebook Graph API share计数字段已弃用?如何获取URL分享数?

获取Facebook分享计数(替代已弃用的share字段)

Hey there! I’ve dealt with this exact problem when working with the Facebook Graph API—since the share field was deprecated in v2.9, we need to use the engagement field as the replacement to fetch share counts. Here's how to make it work:

1. 正确的API请求格式

You’ll need to explicitly request the engagement field (and optionally narrow it down to just share_count for cleaner output) along with a valid access token.

Here’s a sample request:

https://graph.facebook.com/?id=https://stackoverflow.com&fields=engagement{share_count}&access_token=YOUR_APP_ACCESS_TOKEN

关于Access Token的说明

Facebook now requires a valid access token for this endpoint—you can use an app-level access token (no user login required). To get one:

  • Create a Facebook Developer app if you don’t have one
  • Use this endpoint to generate the token:
    https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
    

2. 解析返回结果

The response will include an engagement object containing the share_count you need. Example JSON output:

{
  "engagement": {
    "share_count": 45678
  },
  "id": "https://stackoverflow.com"
}

为什么旧方式不再生效

When you omit the fields parameter, the Graph API only returns a default set of fields (which doesn’t include share metrics anymore). You must explicitly specify engagement to get the share count data.

内容的提问来源于stack exchange,提问作者Lorenzo

火山引擎 最新活动