通过书签使用Facebook API(Using Facebook API via a bookmarklet)

编程入门 行业动态 更新时间:2024-10-27 14:27:39
通过书签使用Facebook API(Using Facebook API via a bookmarklet)

我正在尝试开发一个书签,用于抓取用户当前的网页并存储从中提取的一些数据。 在我自己的网站上,我的用户通过Facebook API登录。

当我的bookmarklet被使用时,我可以成功呈现Facebook登录模式,但是在登录API时会引发异常:

指定的URL不归应用程序所有。

我是新手,但可能这是因为访问bookmarklet的当前页面与我自己的域名不匹配?

我正在从该域上托管的外部文件运行javascript - 这是不够的?

另外,我怎么能得到这个呢? 不幸的是,我无法提供自己的帐户管理功能,并依赖Facebook进行用户管理。

任何解释和创意都值得赞赏。

I am attempting to develop a bookmarklet that scrapes the user's current web page and stores some data pulled from it. On my own website, my users sign in via the Facebook API.

When my bookmarklet is used, I can successfully present the Facebook login modal, but on sign in the API throws an exception:

The specified URL is not owned by the application.

I am new to this, but presumably this is because the current page that the bookmarklet is accessed from doesn't match my own domain?

I am running the javascript from an external file that is hosted on that domain - should that not suffice?

Alternatively, how might I get address this? Unfortunately I can not offer my own account management functionality and am relying on Facebook for my user management.

Any explanations and creative ideas are appreciated.

最满意答案

解决方案是在当前页面上的iframe中,或在新选项卡或新弹出窗口中,在您自己的域内托管登录步骤。 无论如何,任何更少的东西都会过于不安全。

可能的步骤:

Bookmarklet运行并擦除数据。 Bookmarklet使用src =“http://yourdomain.com/bookmarklet-widget?data = ....”创建iframe 如果尚未登录,则窗口小部件内容页面首先需要登录步骤。

如果要使用GET提交大型数据,则可以使用POST。 步骤就像

Bookmarklet运行并擦除数据。 Bookmarklet创建名为“mywidgetframe”的空iframe。 Bookmarklet使用method = post target = mywidgetframe和action =“http://yourdomain.com/bookmarklet-widget”创建表单 Bookmarklet提交表单。 如果尚未登录,则窗口小部件内容页面首先需要登录步骤。

如果您需要在iframe /窗口和当前父页面之间进行直接通信,请查看http://enable-cors.org/

The solution is to host the login step on your own domain within in an iframe on the current page, or in a new tab or new popup window. Anything less would be far too insecure anyway.

Possible steps:

Bookmarklet runs and scrapes data. Bookmarklet creates iframe with src="http://yourdomain.com/bookmarklet-widget?data=...." If not logged in already, the widget content page requires a login step first.

If the data is to large to submit with GET, you can use POST. Steps would be like

Bookmarklet runs and scrapes data. Bookmarklet creates empty iframe with name like "mywidgetframe". Bookmarklet creates form with method=post target=mywidgetframe and action="http://yourdomain.com/bookmarklet-widget" Bookmarklet submits the form. If not logged in already, the widget content page requires a login step first.

If you need direct communication between the iframe/window and the current parent page, check out http://enable-cors.org/

更多推荐

本文发布于:2023-08-07 07:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1462007.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:书签   Facebook   bookmarklet   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!