问题
I'm building a Facebook app that can be installed on Pages (a Page Tab app), and would like to redirect my users to their Page Tabs, knowing only the app ID, and the Page ID.
Let's say for example that my app is installed on this page:
http://www.facebook.com/coldplay whose ID is 15253175252, and my app ID is 174314562666399.
I know I can access the Page using only its numerical ID: http://facebook.com/15253175252 redirects to the Coldplay page.
And I can access the Page Tab with this URL: http://www.facebook.com/coldplay/app_174314562666399. Is there a way to get Facebook to redirect me to this Page Tab using only the Page ID and app ID?
回答1:
You can pass in the APP ID with the sk=app_app_id parameter, but you'll lose it when using the Page ID instead of the Pagename - it's not redirected along with the request.
There's a workaround I've used before though: you'll need to write a FB redirect proof URL from the information you have.
So:
http://facebook.com/pages/-/15253175252?sk=app_174314562666399
That is:
http://facebook.com/pages/-/[page_id]?sk=app_[app_id]
回答2:
There are 3 URL formats that seem to work. Facebook doesn't document the URL format we should be using, so we're left guessing. Here are the 3 formats:
========================
{page.link}?sk=app_{app.id}
The one above broke around November 3, but as of November 25, 2015, it seems to be working again.
========================
@steve's format works well, although it temporarily stopped working on November 24, 2015:
https://facebook.com/pages/-/{page.id}?sk=app_{app.id}
Update 2015-12-22 A client reported that for users who have Norton 360 installed, the above URL format gets reported as a dangerous website and is blocked.
========================
Facebook changed the way they link internally to tab URLs to this format around mid-November, 2015 and it seems to work well. Due to their lack of documentation on this topic, I don't know if they recommend this new format or not:
{page.link}/app/{app.id}
I wish Facebook would officially recommend a tab page URL format for all developers to use, but it's missing from their Page Tab site: https://developers.facebook.com/docs/pages/tabs
If you're interested, you can read about all of the problems that Tab URLs have gone through during the month of November 2015: https://developers.facebook.com/bugs/408615369335909/
来源:https://stackoverflow.com/questions/9585234/find-out-page-tab-url-from-page-id-and-application-id