Facebook iFrame application: How to pass data from URL Query String

吃可爱长大的小学妹 提交于 2019-12-08 23:15:17

问题


I have a Facebook application that has a picture gallery. It's build in Flex 4. I want to allow users to link to a specific image.

How can that be done?

The only way I see this being done is adding a GET var like &my_picture=asd.jpg in the Facebook page URL, but I don't know how to read that from the iFrame.


回答1:


Yes, you can add a parameter to the querystring for this:

http://app.facebook.com/yourapp?myparam=1234

Then, your app will be called like this:

http://domainwhereyouhostyourapp.com/your_fb_app/index.php?myparam=1234

Some other parameters are passed by facebook as well, most related to auth tokens, etc. They are prefixed by "fb_" to prevent name clashes.

In your index.php (or whatever you are using), read the get parameter you're interested in and pass them to your swf as usual.




回答2:


What's great also about Facebook is that it carries EVERYTHING after your ../appname/{things-beyond-your-app-name} to you hosted [server] URL... so that even .htaccess can be used. ;)

Like this...

http://apps.facebook.com/YOURAPPNAME/a/b/c.htm

For an app that's hosted on my server at:

http://example.com/APPSHOSTEDPATH/

and by using this one-liner included in my hosted location's .htaccess file in:

http://example.com/APPSHOSTEDPATH/

where .htaccess file contains (among the other standard) lines...

I can put something like:

RewriteRule ^(.*)$ /myRedirectedPath/$1 [L,R=301]

So if the person goes to: http://apps.facebook.com/YOURAPPNAME/a/b/c.htm (as in the above example)

They'll stay there and they'll be accessing:

http://example.com/myRedirectedPath/a/b/c.htm

(pretty sweet, eh?) ;)

Fun stuff... wanted you to know that there's more capability that just $_GET's.



来源:https://stackoverflow.com/questions/3175300/facebook-iframe-application-how-to-pass-data-from-url-query-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!