简体   繁体   中英

Using Facebook Dialog in Windows 8 HTML5/JavaScript App

I am following the dialog documentation to try to display dialog in a Windows 8 Store app (html5/javascript).

https://developers.facebook.com/docs/reference/dialogs/

In a Windows 8 Store app, we have to use iframe to display another web page. Here is an example of what I did:

<iframe src="https://www.facebook.com/dialog/feed?app_id=145634995501895&redirect_uri=http://www.facebook.com&show_error=true&display=iframe&access_token={access_token}"></iframe> 

Since it is an iframe, I specify display=iframe and access_token={access_token}. If you want to try it, please remember to change access_token.

I get the following errors:

API Error Code: 110
API Error Description: Invalid user id
Error Message: Missing user cookie (to validate session user)

在此处输入图片说明

I guess this may be caused by the fact that user has not login yet. In the documentation ( https://developers.facebook.com/docs/reference/dialogs/ ), it said "If the user is not already logged in, Facebook will prompt them to login before showing the the Dialog you invoked." I am wondering how to prompt the user to login? Did I miss a parameter to prompt user to login? I looked through the parameters, I did not seem to find anything.

Appreciate your help.

I am seeing different behavior from you which I'll document here, even though it may not be "your answer".

I obtained my own access token, and when I use your IFRAME, I do see the attempt to redirect to Facebook.com to login; however, that's followed by a security error in the JavaScript console - including the following:

APPHOST9613: The app couldn't navigate to https://www.facebook.com/login.php?api_key=177388709024886&skip_api_login=1 ... because of this error: FORBIDFRAMING.

A request to the login.php script generates a response with the X-FRAME-OPTIONS header to DENY. This would indeed prevent the login page from Facebook from appearing in the IFRAME within the app - hence FORBIDFRAMING.

There is some discussion on an MSDN Forum thread as well and it's slightly dated, but am not aware of any changes since then.

I have not tried Facebook logins directly with Window 8 applications using Windows Azure Mobile Services , but it may be something to try. Azure Mobile Services is VERY simple to set up, so you'll know very quickly whether or not there is still an issue within a HTML5/JS Windows Store app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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