Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Application Tab -> External Linking with PHP

Tags:

php

facebook

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 application (which is searching books), finds a book they like, and wants to share it with a friend. They click to share it, and I can pull all the info, however I don't have a deep link so when it's emailed, facebooked, ect.. it sends the user directly to the page with it on it.

Is this possible on the Application Tab? I know on the canvas I could deep link fine... but looking for a way to do it on the App Tab.

Thank you for your thought and responses.

like image 650
Petrogad Avatar asked Aug 19 '10 17:08

Petrogad


2 Answers

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.

like image 156
gerard Avatar answered Sep 30 '22 20:09

gerard


Perhaps.

For Application Canvas Pages, Facebook forwards any addition URI information to your canvas callback.

For example, if your app page is http://apps.facebook.com/testapp

and your canvas callback is http://facebook.example.com/testapp/canvas

Then going to http://apps.facebook.com/testapp/foo?bar=baz would result in facebook's servers hitting yours like so http://facebook.example.com/testapp/canvas/foo?bar=baz.

I've never tested it to see if application tabs share this behavior, but it's worth a shot. If so, you could just use URI information to drive your deeplinking.

Also, you should be aware of the impending changes to application tabs.

like image 40
Peter Bailey Avatar answered Sep 30 '22 19:09

Peter Bailey