Facebook Application Tab -> External Linking with PHP

后端 未结 4 789
失恋的感觉
失恋的感觉 2021-02-01 07:58

I currently have an Application on the Facebook Tab, and am wondering if there is a way for me to deep link into an item on that app tab. Example:

User is in the applic

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 08:21

    Here's how we deep link to subpages within our app's Page Tab.

    When your application lives inside a Page Tab, Facebook will strip out all GET params except for app_data. It passes app_data inside the signed_request parameter of the POST data.

    More info in the docs: https://developers.facebook.com/docs/authentication/signed_request/

    So when we build links to subpages, it will look something like

    http://www.facebook.com/myfanpage?sk=app_XXXXXX&app_data=%2Fmainpage%2Fsubpage
    

    Then, in our index page code, we check for the app_data param. If it exists, then a simple 302 redirect does the trick.

    $request = parse_signed_request($_POST['signed_request']);
    if ($request['app_data'])
    {
        header('HTTP/1.1 302 Found');
        header('Location: {$request['app_data']}');
        exit;
    }
    

    Note: you can pass more than 1 param inside of app_data using a URL-encoded, JSON-array or something like that.

提交回复
热议问题