使用 Delicious API 在 Firefox 中创建 Delicious 书签
我想在 Firefox 中创建一个 Delicious 小书签,用预定义的标签为当前页面添加书签。
为了概念证明,如果我输入此网址,它会起作用:
https://john:[email protected]/v1/posts/add?url=http://www.google.com&
description=http://www.google.com&tags=testtag
但这作为一个小书签却不能,我得到访问被拒绝:
javascript:(
function()
{
location.href = 'https://john:[email protected]/v1/posts/add?url='
+ encodeURIComponent(window.location.href)
+ '&description=' + encodeURIComponent(document.title)
+ '&tags=testtag';
}
)()
这可以通过 JavaScript 书签实现吗?
更新:我尝试了这个,但仍然收到访问被拒绝错误,所以它与Javascript/Firefox有关。
javascript:(
function()
{
location.href = 'https://john:[email protected]/v1/posts/add?url='
+ 'http://www.google.com'
+ '&description=' + 'http://www.google.com' + '&tags=testtag';
}
)()
更新2: 在尝试了上述方法的多种变体并在不同的浏览器上尝试之后,我仍然无法克服访问被拒绝的消息,因此提供了赏金。
I want to create a Delicious bookmarklet in Firefox that bookmarks the current page with a predefined tag.
For proof of concept, if I enter this url, it works:
https://john:[email protected]/v1/posts/add?url=http://www.google.com&
description=http://www.google.com&tags=testtag
But this as a bookmarklet doesn't, I get access denied:
javascript:(
function()
{
location.href = 'https://john:[email protected]/v1/posts/add?url='
+ encodeURIComponent(window.location.href)
+ '&description=' + encodeURIComponent(document.title)
+ '&tags=testtag';
}
)()
Is this possible via a javascript bookmark?
Update: I tried this, but still got the access denied error, so it has something to do with Javascript/Firefox.
javascript:(
function()
{
location.href = 'https://john:[email protected]/v1/posts/add?url='
+ 'http://www.google.com'
+ '&description=' + 'http://www.google.com' + '&tags=testtag';
}
)()
Update 2:
After trying many variations of the above and on different browsers, I still can't get past the access denied message, so offering a bounty.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑这是 Firefox 试图保护您在运行 Javascript 时免受安全问题的影响。当我尝试在地址栏中输入您的示例时,Firefox 提示我询问是否确定要登录
api.del.icio.us
。关于 HTTP auth 的其他问题看起来与您的问题类似,也许它会帮助你的。
更新:
我使用了 Firebug 的 Net 面板及其 Javascript 控制台,并且我能够看到请求/响应标头。
这是来自 Javascript 控制台的请求,该请求失败:
并且,这是来自地址栏的请求,该请求有效:
唯一的区别似乎是
Referer
标头,它导致访问拒绝回应。 Firefox about.config 中的 network.http.sendRefererHeader 设置可以设置为 0,从而关闭Referer
标头。当我尝试这个时,Javascript 控制台方法开始工作。有一个名为 refspoof 的 Firefox 扩展,可用于发送您自己的自定义
Referer< /code> headers,也许这可以帮助这里。
I suspect this is Firefox trying to protect you from security issues when running Javascript. When I tried typing in your example into my address bar, Firefox prompted me to ask if I am sure I want to log in to
api.del.icio.us
.This other question concerning HTTP auth looks similar to your question, maybe it will help you.
Update:
I used Firebug's Net panel and its Javascript console, and I was able to see the request/response headers.
Here is the request from the Javascript console, which FAILED:
And, here is the request from the address bar, which WORKED:
The only difference seems to be the
Referer
header, which caused the access denied response. The setting network.http.sendRefererHeader in Firefox's about.config can be set to 0 which turns off theReferer
header. When I tried this, then the Javascript console method started working.There is a Firefox extension called refspoof which is useful for sending your own custom
Referer
headers, maybe that can help here.您似乎缺少
url=
。Looks like you're missing
url=
.