如何从Leadgen表单及线索生成Webhook获取用户FBID?
Got it, let's break this down clearly. You're correct that the LeadgenInfo Node doesn't directly surface the user's global FBID, but we can grab the right identifiers—either the Page Scoped ID (PSID, which is all you need for most use cases) or the global FBID if you absolutely require it—through the Leadgen Webhook or API.
一、从Leadgen Webhook直接拿PSID
When a user submits a Leadgen form linked to your Facebook Page, the Webhook payload already includes their PSID. This ID works perfectly for sending automated Messenger replies and fetching their public profile data.
Look for this field in the Webhook payload:
entry[0].changes[0].value.lead.user_id
That user_id is the user's PSID. You can immediately use it to call the Messenger API's /me/messages endpoint for automated replies, or hit /{psid} to pull public profile details like name and profile picture.
二、通过Leadgen API获取用户标识
If you need to fetch additional context later, use the leadgen_id from the Webhook payload to call the Leadgen API endpoint:
GET /v18.0/{leadgen_id}?access_token=YOUR_ACCESS_TOKEN
In the response, the user.id field will be the same PSID from the Webhook—this is useful if you need to re-fetch lead details after the initial Webhook trigger.
三、获取全局FBID(仅当必须时)
If your workflow strictly requires the user's global FBID (not just the PSID), you’ll need two things:
- Your app must have the
public_profilepermission (or relevant user data permissions) - The user must have authorized your app
With those in place, call the Graph API with the PSID:
GET /v18.0/{psid}?fields=id&access_token=YOUR_ACCESS_TOKEN
The returned id will be the user's global FBID. Note that without user authorization, this will just return the PSID instead.
Quick Notes to Keep in Mind
- PSID is sufficient for 99% of Messenger automation and profile needs—don’t overcomplicate things by chasing the global FBID unless you have a specific reason
- Double-check that your Webhook is subscribed to the
leadgenfield and that your access token has the necessary permissions to read lead data - Always use the latest version of the Facebook Marketing API to avoid compatibility hiccups
内容的提问来源于stack exchange,提问作者STeveBobJohn

