问题
Short version
I have a facebook iframe app as a page tab on a fan page. The app collects entries for a contest. It lists the entries and also has a page for showing a single entry. I want to be able to link to the single-entry page - I have this working using the app_data
parameter, but only if the user has used the app before. This does not work for a new user who has to add the app (log in).
Long version
So far I've managed to get this partially working by linking to
http://facebook.com/pages/<myPageName>/<myPageId>?sk=app_<myAppID>&app_data=<myUrlEncodedJsonData>
The app_data
parameter is passed on to my application's iframe by facebook and I can then process it server-side to redirect the user to the appropriate subpage. All seems to work well... but only if I had logged into the application before trying to access the deep-linked content.
If I try to deep link to the single-entry page and don't have the application installed yet (scenario: I'm a friend of a contestant and I've been encouraged to vote for his entry, I haven't used the app yet), then, after logging in, I'm on the index page of my app, and that is not what I'm after.
I'm using PHP facebook SDK to obtain a loginUrl like this:
$loginUrl = $facebook->getLoginUrl(array('canvas' => 1,'fbconnect' => 0, 'scope' => 'email,publish_stream,offline_access,user_likes,publish_actions', 'next' => $canvasPage));
where $canvasPage
is the full URL of the app on my server, $loginURL
is where I redirect the user if I detect he is not logged in my application.
What should I change to be able to direct new users straight to specific content (subpage) within my app?
回答1:
Solved. I used session to store where the user wants to get initially, then redirect him to the login page, and when he/she's back, session is read to redirect the user to the final destination.
来源:https://stackoverflow.com/questions/8445495/facebook-app-deep-link-for-new-app-user