简体   繁体   English

链接到 Facebook iframe 内的页面

[英]Link to a page within Facebook iframe

Im looking for a way to link to a webpage within a facebook iframe page我正在寻找一种方法来链接到 facebook iframe 页面中的网页

so所以

http://www.facebook.com/designmystyle/app_244351832329915

would be something like会是这样的

http://www.facebook.com/designmystyle/app_244351832329915?http://www.lickmystyle.com/contact/

I have tried the method here http://www.codingforums.com/archive/index.php/t-85547.html using我在这里尝试了该方法http://www.codingforums.com/archive/index.php/t-85547.html使用

    <script type="text/javascript">
    <!--

    function loadIframe(){
    if (location.search.length > 0){
    url = unescape(location.search.substring(1))

    window.frames["app_runner4f84331f0576e6f73380702"].location=url
    }
    }

    onload=loadI

frame
//-->

Im unsure if app_runner4f84331f0576e6f73380702 is the name or the id of the iframe but it was the only one I could find that had a width of 810px by 800px我不确定 app_runner4f84331f0576e6f73380702 是 iframe 的名称还是 ID,但这是我能找到的唯一一个宽度为 810px x 800px 的

Any ideas on if this could be done would be great关于是否可以做到的任何想法都会很棒

If it's a facebook canvas app then the url for it should be of apps.facebook.com and not www.facebook.com .如果它是 facebook canvas 应用程序,那么 url 应该是apps.facebook.com而不是www.facebook.com

Any querystring parameter that will be added to your canvas app url will be then passed by facebook to your app by adding it to the url of your app when loaded inside the canvas iframe, so if you direct the user to:任何将添加到您的 canvas 应用程序 url 的查询字符串参数然后将通过 facebook 传递给您的应用程序,方法是在 canvas iframe 中加载时将其添加到您应用程序的 url,因此如果您将用户引导至:

apps.facebook.com/app-name?param=value apps.facebook.com/app-name?param=value

facebook will POST the app canvas iframe to: facebook 会将应用程序 canvas iframe 发布到:

www.yourdomain.com/canvas-path?param=value www.yourdomain.com/canvas-path?param=value

Then you can get that parameter like any other GET parameter and what you want with it.然后,您可以像任何其他 GET 参数一样获取该参数以及您想要的参数。 One thing though, if that parameter is a url then it should be url encoded, other wise things will go wrong.但是有一件事,如果该参数是 url 那么它应该是 url 编码,否则 go 是错误的。

What I don't understand is what you're trying to do with the url that you want to pass as a parameter, what is this "app_runner4f84331f0576e6f73380702"?我不明白的是你想用你想作为参数传递的 url 做什么,这个“app_runner4f84331f0576e6f73380702”是什么?


Edit编辑

Oh, it's a page tab, sorry, I missed that part.哦,这是一个页面选项卡,抱歉,我错过了那部分。

I'v never used it before, but it says in the last section ( Integrating with Facebook APIs ) of the Page Tab Tutorial :我以前从未使用过它,但它在页面选项卡教程的最后一节(与 Facebook API 集成)中说:

your app will also receive a string parameter called app_data as part of signed_request if an app_data parameter was set in the original query string in the URL your tab is loaded on.如果在加载选项卡的 URL 中的原始查询字符串中设置了 app_data 参数,则您的应用程序还将收到一个名为 app_data 的字符串参数作为 signed_request 的一部分。 For the Shop Now link above, that could look like this: "http://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here".对于上面的“立即购买”链接,它可能如下所示:“http://www.facebook.com/YourPage?v=app_1234567890&app_data=any_string_here”。 You can use that to customize the content you render if you control the generation of the link.如果您控制链接的生成,则可以使用它来自定义呈现的内容。

From what I understand, this is exactly what you need in order to get the data.据我了解,这正是您获取数据所需要的。

How ever, you won't be able to change the url of the iframe the way you posted since you have no access to the parent window (your page is on different domain than of facebook, and the browser will prevent it due to the cross-domain policy).但是,您将无法按照发布方式更改 iframe 的 url,因为您无权访问父 window(您的页面与 facebook 位于不同的域中,并且浏览器会阻止它由于交叉-域策略)。

What you can do how ever is just:你能做的只是:

document.location.href = URL;

You are in your own page, doesn't matter that it resides in an iframe.您在自己的页面中,它位于 iframe 中并不重要。

The thing is that you don't need all of that, just be aware in the server side of the parameter that is passed to you from facebook (from the query string) if such exists, and render the page according to that.问题是您不需要所有这些,只要在服务器端了解从 facebook(来自查询字符串)传递给您的参数(如果存在),并根据该参数呈现页面。 There's no reason to render a page that then redirects the page to another url, when you already know what the user wants, you're just making the user make a redundant round trip to your server for nothing.没有理由呈现一个页面然后将页面重定向到另一个 url,当您已经知道用户想要什么时,您只是让用户免费往返您的服务器。

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

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