Search code examples
phpfacebookfacebook-graph-apifacebook-webhooks

Facebook Webhook User ID seems incorrect?


I created a small script to handle all webhooks from Facebook feed. The goal is to detect when a page goes live and get all comments from that live video. So far, everything is working well: I receive all the necessary information, including comments with the from ID and from Name.

However, I've encountered an issue where the from ID doesn't seem to be correct. If I try to navigate to facebook.com/FROM_ID, I get an error. After fetching some data and comparing it against known user IDs, I noticed they don't match at all. I wonder if this is normal, a bug, or some kind of encryption.

Issue The from ID received in the webhook payload seems incorrect.

Here is an example of the payload I'm receiving:

Array
(
    [entry] => Array
        (
            [0] => Array
                (
                    [id] => 1xxxxxxxxxxxxxx
                    [time] => 1716213862
                    [changes] => Array
                        (
                            [0] => Array
                                (
                                    [value] => Array
                                        (
                                           ** [from] => Array
                                                (
                                                    [id] => 1xxxxxxxxxxxxxx
                                                    [name] => User Name
                                                )**

                                            [post] => Array
                                                (
                                                    [status_type] => added_video
                                                    [is_published] => 1
                                                    [updated_time] => 2024-05-20T14:04:16+0000
                                                    [permalink_url] => https://www.facebook.com/MYPAGE/
                                                    [id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx
                                                )

                                            [message] => Some Random Message
                                            [post_id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx
                                            [comment_id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx
                                            [created_time] => 1716213856
                                            [item] => comment
                                            [parent_id] => 1xxxxxxxxxxxxxx_1xxxxxxxxxxxxxx
                                            [verb] => add
                                        )

                                    [field] => feed
                                )

                        )

                )

        )

    [object] => page
)

Questions

  • Is it normal for the from ID in webhook events to not match the expected user ID format?
  • Is there any encryption or obfuscation applied to the from ID?
  • Has anyone else faced this issue, and how did you resolve it?

Additional Information

Thank you!

Graph API Requests: I tried using the Graph API with the from ID to fetch basic user information but received errors.

Searching for Similar Issues: I searched extensively for similar issues related to Facebook webhooks but couldn’t find any relevant solutions.


Solution

  • These IDs are per-app obfuscated IDs known as app scoped IDs.

    The IDs are only valid for API usage, unless the user_link scope is requested and approved by Facebook. If that scope is approved and the user authorizes it, the links become functional in-browser.

    The user_link permission allows your app to access the Facebook profile URL of the person using your app.