简体   繁体   English

在Windows 8 HTML5 / JavaScript应用中使用Facebook对话框

[英]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). 我正在遵循对话框文档,以尝试在Windows 8 Store应用程序(html5 / javascript)中显示对话框。

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

In a Windows 8 Store app, we have to use iframe to display another web page. 在Windows 8 Store应用程序中,我们必须使用iframe来显示另一个网页。 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}. 由于它是iframe,因此我指定了display = iframe和access_token = {access_token}。 If you want to try it, please remember to change access_token. 如果要尝试,请记住更改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." 在文档( https://developers.facebook.com/docs/reference/dialogs/ )中,它说:“如果用户尚未登录,Facebook将在显示您调用的对话框之前提示他们登录。” 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; 我获得了自己的访问令牌,并且在使用您的IFRAME时,确实看到了尝试重定向到Facebook.com进行登录的尝试; however, that's followed by a security error in the JavaScript console - including the following: 但是,这之后是JavaScript控制台中的安全错误-包括以下内容:

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. APPHOST9613:该应用无法导航至https://www.facebook.com/login.php?api_key=177388709024886&skip_api_login=1 ...,因为存在此错误:FORBIDFRAMING。

A request to the login.php script generates a response with the X-FRAME-OPTIONS header to DENY. 对login.php脚本的请求生成带有X-FRAME-OPTIONS标头的DENY响应。 This would indeed prevent the login page from Facebook from appearing in the IFRAME within the app - hence FORBIDFRAMING. 实际上,这确实会阻止来自Facebook的登录页面出现在应用程序的IFRAME中-因此是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. MSDN论坛线程上也有一些讨论,虽然讨论的时间过短 ,但是从那时起就不知道有任何更改。

I have not tried Facebook logins directly with Window 8 applications using Windows Azure Mobile Services , but it may be something to try. 我尚未尝试使用Windows Azure移动服务直接使用Window 8应用程序登录Facebook,但这可能是尝试的方法。 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. Azure移动服务的设置非常简单,因此您将很快知道HTML5 / JS Windows Store应用程序中是否仍然存在问题。

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

相关问题 使用Javascript和html5的Windows应用程序的Facebook登录 - Facebook login for Windows app using Javascript and html5 Windows 8 JavaScript HTML5应用程序无法解析xml - Windows 8 javascript html5 app not parsing xml 如何在Windows 8商店HTML5 / javascript应用程序中使用javascript保存iframe的内容? - How to save content of the iframe using javascript in Windows 8 store HTML5/javascript app? 如何使用javascript / html5在Windows Phone 8.1应用程序中禁用视频预览的自动旋转 - How to disable auto rotate for a video preview in a Windows Phone 8.1 App using javascript/html5 使用HTML5,CSS3和Javascript进行Windows Phone 8.1应用程序开发 - Using HTML5, CSS3, and Javascript for Windows Phone 8.1 App Development Windows 8 JavaScript App开发:在HTML5 Canvas上绘制 - Windows 8 JavaScript App Development: Draw on HTML5 Canvas Windows 8 Metro风格javascript / html5应用中的免费位图内存 - free bitmap memory in windows 8 metro style javascript/html5 app Windows应用商店应用Javascript / HTML5连接到数据库 - Windows Store App Javascript/HTML5 connect to Database 如何使用HTML5将应用栏添加到Windows Phone 8应用 - How to add an app bar to a Windows Phone 8 app using HTML5 用于文件下载的 HTML5/JavaScript“另存为”对话框 - HTML5/JavaScript "Save As" Dialog for File Download
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM