请求协助:获取Facebook分享页面的点赞数(API调用问题)
Got it, let's break down how to retrieve the like count for your shared external page (e.g., www.example.com/test-page) on Facebook. Your previous API calls were targeting the wrong data structure—here's the correct approach:
Step 1: Get the Facebook Share Object ID for Your URL
When you share an external URL to Facebook, the platform creates a unique share object linked to that URL. You first need to fetch this object's ID using the Graph API:
GET https://graph.facebook.com/v18.0/?id=https://www.example.com/test-page&access_token=YOUR_ACCESS_TOKEN
The response will include an id field—this is the unique identifier for your URL's Facebook share object (e.g., 12345678901234567).
Step 2: Fetch the Like Count Using the Share Object ID
Once you have the share object ID, you can query it directly to get the like count. You have two reliable options:
Option 1: Use the like_count Field
This field returns the total number of likes for the share object:
GET https://graph.facebook.com/v18.0/[SHARE_OBJECT_ID]?fields=like_count&access_token=YOUR_ACCESS_TOKEN
Option 2: Target Specific Reactions (Likes Only)
If you want to exclude other reaction types (e.g., Love, Haha) and only count pure likes, use the reactions endpoint with a filter:
GET https://graph.facebook.com/v18.0/[SHARE_OBJECT_ID]?fields=reactions.type(LIKE).summary(total_count).limit(0)&access_token=YOUR_ACCESS_TOKEN
The summary.total_count value in the response will be your exact like count.
Key Notes
- API Version: Always use the latest stable Graph API version (e.g., v18.0 or newer) to avoid deprecated fields.
- Access Token Permissions: For public share objects, a valid app access token is sufficient. If the content is restricted, you may need a user access token with appropriate permissions (e.g.,
pages_read_engagement). - URL Crawling: If your URL hasn't been shared on Facebook before, you may need to trigger a crawl first using Facebook's official share debugging tool to generate the share object.
内容的提问来源于stack exchange,提问作者sethu kumar




