如何通过Facebook PHP SDK获取他人发布到我主页的帖子及发布者信息?
Great question—this is a common pain point with the modern Facebook Graph API, but there is a way to pull off what you're trying to do for your tie strength script. Let's break it down step by step:
Key Background & Fix
First, let's clarify the endpoints:
/me/postsonly returns posts you've created yourself—this is why you're not seeing others' content here./me/feedincludes all content that appears on your timeline, including posts friends have made directly to your profile, shares, and more.
The issue you're hitting (missing publisher IDs/names) is almost certainly because you're not explicitly requesting the from field in your API call. The Graph API no longer returns all fields by default; you have to specify exactly what data you want.
How to Get the Publisher Data
When you call /me/feed, add the from field (with nested id and name parameters) to your request. Here's an example of the API call format:
GET /me/feed?fields=id,from{id,name},message,created_time
This will return a from object for every post in your feed, which includes the unique ID and full name of the person who created the post.
Filter & Count Posts
Once you have this data, you can:
- Filter out any posts where
from.idmatches your own user ID (these are posts you created yourself) - Group the remaining posts by
from.id(to avoid name collisions) and count how many times each friend appears—this gives you their post count on your profile.
Critical Permissions Note
To access this data, your access token needs the user_posts permission. For personal use (e.g., analyzing your own profile), you can generate a token with this permission in the Facebook Developer Tools' Graph API Explorer. Keep in mind that for public apps, this permission requires strict app review from Facebook, so it's only feasible for personal projects right now.
Pagination Consideration
If you have a lot of timeline content, the API will return results in pages. You'll need to use the after parameter from the paging object in each response to fetch subsequent pages until there are no more results left.
内容的提问来源于stack exchange,提问作者Garry Welding

