Facebook Application Tab -> External Linking with PHP

后端 未结 4 780
失恋的感觉
失恋的感觉 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:18

    For those that need a full (yet minimal working) example (like myself) here is the index.php which does the deep-linking when needed. Make sure you've downloaded the Facebook PHP SDK and that your require path points to it. (Obviously, you also need to replace the $app_id and $app_secret with your own app info.)

     $app_id,
        'secret' => $app_secret
    ));
    
    $signed_request = $facebook->getSignedRequest();
    
    // Get app_data from signed request POST
    $app_data = $signed_request["app_data"];
    
    // Parse app_data & Re-direct
    if ($app_data) {
        header("HTTP/1.1 302 Found");
        header("Location: {$app_data}");
    exit;
    }
    
    ?>
    
    
    
        Title Here
    
    
        

    Landing Page

    Also, make sure that within your FB App Settings, all your URL paths (i.e. Canvas URL, Page Tab URL, etc) end with a backslash, or else you'll get some 301 redirect errors.

    Once your app is setup and you've added it your fan page, you can deep link with something like:

    http://www.facebook.com/pages/MYFANPAGE/XXXXX?sk=app_XXXXX&app_data=sub/another.php
    

    You may have to parse the actual app_data value before using it, but for me it worked just as above.

    Hope that helps others out there. Of course, Facebook may change all this at any time.

提交回复
热议问题