Facebook应用程序选项卡->用PHP进行外部链接 [英] Facebook Application Tab -> External Linking with PHP

查看:45
本文介绍了Facebook应用程序选项卡->用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:

用户位于应用程序中(正在搜索书籍),找到他们喜欢的书,并希望与朋友分享.他们单击以共享它,我可以拉出所有信息,但是我没有一个深层链接,因此当通过电子邮件,facebook等将其发送给用户时,它会将用户直接定向到带有该信息的页面.

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.

感谢您的想法和回应.

推荐答案

这是我们深度链接到应用程序的页面"标签中的 子页面的方式.

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

当您的应用程序位于页面"选项卡中时,Facebook将删除除app_data之外的所有GET参数.它在POST数据的signed_request参数内传递app_data.

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.

文档中的更多信息: 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

然后,在索引页代码中,检查app_data参数.如果存在,那么简单的302重定向就可以解决问题.

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;
}

注意:您可以使用URL编码的JSON数组等在app_data内部传递多个参数.

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

这篇关于Facebook应用程序选项卡->用PHP进行外部链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆