简体   繁体   English

链接到Facebook应用程序框架的最佳方法是什么?

[英]What is the best way to link into the frame of Facebook application?

I have a pure iframe Facebook app in PHP. 我有一个纯PHP的iframe Facebook应用。 By being pure I want to say it has no meaning to approach it's in-iframe URLs directly. 纯粹来说,我想说直接进入iframe内网址没有任何意义。 If someone accidentaly approached (eg by opening a link from the inside of app in a new tab) URL of the app outside of iframe, my app can recognize it by JavaScript and redirects to it's version in iframe. 如果有人意外访问(例如,通过在新选项卡中打开应用内部的链接)iframe外部的应用URL,则我的应用可以通过JavaScript识别它并重定向到iframe中的版本。

However, my desired behavior is to send the user to the same URL he wanted to approach, only inside Facebook platform iframe. 但是,我想要的行为是仅在Facebook平台iframe内将用户发送到他想使用的相同URL。 Example: 例:

What would be the best solution in your opinion? 您认为最好的解决方案是什么? I thought about sessions, do they have any drawbacks? 我考虑过会议,它们有什么缺点吗? I can save original location and start redirect to iframe, then find out what was the location and redirect to that page inside the iframe. 我可以保存原始位置并开始重定向到iframe,然后找出位置并重定向到iframe中的该页面。 How can I ensure the user who is being redirected doesn't interrupt the process and doesn't cause any unpredictible redirects later due to the saved but not resolved one? 如何确保要重定向的用户不会中断该过程,并且以后不会由于保存但未解决的重定向而导致任何不可预测的重定向? What about user having multiple tabs with my app? 用户在我的应用中具有多个标签该怎么办? Tabs could steal redirects one from the another... 标签页可能会窃取彼此之间的重定向...

例如,将用户重定向到https://apps.facebook.com/my-awesome-app/?page=help并分析应用程序中的查询(或使用httpd重写规则)。

The below are my findings with respect to Page Tab apps. 以下是我对Page Tab应用程序的发现。 It may not be true at all for App on Facebook apps. 对于App on Facebook应用App on FacebookApp on Facebook可能根本不正确。

Normally, Facebook will not pass on query string parameters to the URL of your iframe, so you can't go the facebook.com/.../my_app?where=help&page=2 way. 通常,Facebook不会将查询字符串参数传递给iframe的URL,因此您不能采用facebook.com/.../my_app?where=help&page=2方式。

It will however pass on the app_data paramater inside the signed request (it is the only exception to the rule AFAIK). 但是,它将在已签名的请求内传递app_data参数(这是规则AFAIK的唯一例外)。 But this leaves you with only one parameter to play with. 但这仅使您可以使用一个参数。 You can counter that, by making it a url-encoded JSON object, containing in fact many variables. 您可以通过将其设为包含许多变量的url编码JSON对象来对此进行反击。 Example: 例:

facebook.com/.../my_app?app_data=%7bwhere%3a+%22help%22%2c+page%3a+2%7d

Which on the server side you receive by json_decode($signedRequest['app_data']) and receiving 在服务器端,您通过json_decode($signedRequest['app_data'])接收并接收

array(
    'where' => 'page',
    'page' => 2
)

From here on, it is up to you to perform the redirects. 从这里开始,由您决定执行重定向。 You won't have to use sessions, unless your user is not logged in to facebook and / or your app. 除非您的用户未登录Facebook和/或您的应用程序,否则您无需使用会话。 Then you'd have to complicate this a little. 然后,您必须将其复杂化一点。 My solution was to use sessions for the not-logged-in scenario: Facebook app - deep link for new app user 我的解决方案是针对未登录的情况使用会话: Facebook应用程序-新应用程序用户的深层链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 解析Facebook朋友字符串的最佳方法是什么? - What is the best way to parse Facebook friends string? 什么是在网站链接中编码参数的最佳方法 - What is the best way to encode parameters in website link 使用会话变量保护应用程序安全的最佳方法是什么? - What is the best way to secure an application with session vars? 保持PHP应用程序setings的最佳方法是什么? - What is the best way to persist PHP application setings? Facebook 朋友过滤数据库记录的最佳方法是什么? - What's the best way to filter database records by Facebook friends? 前端控制器将参数链接到应用逻辑的最佳方法? - Front controller best way to link parameters to application logic? 将Codeigniter项目连接到Facebook API的最佳方法是什么? - What is the best way to connect a Codeigniter project to the Facebook API? 从Android应用程序链接检索ID的最佳方法是什么? - what is the best way to retrieve id from android app link? 实现链接 yii2 -> React js 的最佳方法是什么? - What is the best way to implement a link yii2 -> React js? 制作可链接到4个不同网站的小部件的最佳方法是什么? - What would be the best way to make a widget that will link to 4 different websites?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM