简体   繁体   中英

How to deep link to a Facebook App (NOT Page Tab)

I need to link to a specific page in my Facebook app. The app is not in a page tab, and cannot be in one due to the project constrictions.

This is the url format: https://apps.facebook.com/myappname

I would need to pass a parameter at the end (like /next.html or ?page=next) so that I can link to the specific page directly from outside the app (from an email).

How would I set this up? My project uses PHP and jQuery. I would love to be able to do this strictly in Javascript if possible.

I have found tons of info on how to deep link a page tab or a mobile app, but not to a regular application. I have found messages stating it's possible, but nothing about how to actually do it anywhere online or on Facebook.

Thanks for your help.

EDIT:

Okay, I got it working in PHP. For anyone else with this issue, this is what I did.

Add a "?" at the very end of the 'Site URL' in your FB app, then create a redirect file similar to this as your app landing page (just use absolute paths instead of relative ones like I did below):

<?php
$query = $_SERVER['QUERY_STRING'];
$params = explode("/", $query);

if (in_array("gallery", $params)) {
    header("Location: /gallery.html");
    exit;
}
else {
    header("Location: /index.html");
    exit;
}
?>

This answer is what helped me figure this out: $_GET on facebook iframe app

I may be missing something here, but why don't you just link to http://apps.facebook.com/yourapp/something.php - this should automatically load your canvas URL, with something.php appended to the path

Obviously this won't work if your canvas URL points to a specific file and not a directory, but plenty of apps do this with success

You get a special parameter called app_data that you can use however you want. I've used it in the past to encode a full querystring of my internal app. for example, &app_data=My/Custom/Page

More found in this SO question: Retrieve Parameter From Page Tab URL

When you are using the ? all you are doing is issuing a $_GET request, so all of the info you require will exist in the $_GET array.

Rather than query the $_SERVER array, query the $_GET array.

So if you had:

http://myurl.com?info=foobar

You can simply access that info using:

$info = $_GET['info'];

It is good practice to check for the existence first though:

if (isset($_GET['info']))
{
$info =$_GET['info'];
}
else
{
$info="default";
}

Incidently if you use the & character you can have multiple parameters:

http://myurl.com?info=foo&moreinfo=bar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM