最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Http Auth in a Firefox 3 bookmarklet - Stack Overflow

programmeradmin3浏览0评论

I'm trying to create a bookmarklet for posting del.icio.us bookmarks to a separate account.

I tested it from the mand line like:

wget -O - --no-check-certificate \
"https://seconduser:[email protected]/v1/posts/add?url=;description=test"

This works great.

I then wanted to create a bookmarklet in my firefox. I googled and found bits and pieces and ended up with:

javascript:void(
    open('https://seconduser:[email protected]/v1/posts/add?url='
          +encodeURIComponent(location.href)
          +'&description='+encodeURIComponent(document.title),
          'delicious','toolbar=no,width=500,height=250'
        )
    );

But all that happens is that I get this from del.icio.us:

<?xml version="1.0" standalone="yes"?>
<result code="access denied" />
<!-- fe04.api.del.ac4.yahoo unpressed/chunked Thu Aug  7 02:02:54 PDT 2008 -->  

If I then go to the address bar and press enter, it changes to:

<?xml version='1.0' standalone='yes'?>
<result code="done" />
<!-- fe02.api.del.ac4.yahoo unpressed/chunked Thu Aug  7 02:07:45 PDT 2008 -->

Any ideas how to get it to work directly from the bookmarks?

I'm trying to create a bookmarklet for posting del.icio.us bookmarks to a separate account.

I tested it from the mand line like:

wget -O - --no-check-certificate \
"https://seconduser:[email protected]/v1/posts/add?url=http://seet.dk&description=test"

This works great.

I then wanted to create a bookmarklet in my firefox. I googled and found bits and pieces and ended up with:

javascript:void(
    open('https://seconduser:[email protected]/v1/posts/add?url='
          +encodeURIComponent(location.href)
          +'&description='+encodeURIComponent(document.title),
          'delicious','toolbar=no,width=500,height=250'
        )
    );

But all that happens is that I get this from del.icio.us:

<?xml version="1.0" standalone="yes"?>
<result code="access denied" />
<!-- fe04.api.del.ac4.yahoo unpressed/chunked Thu Aug  7 02:02:54 PDT 2008 -->  

If I then go to the address bar and press enter, it changes to:

<?xml version='1.0' standalone='yes'?>
<result code="done" />
<!-- fe02.api.del.ac4.yahoo unpressed/chunked Thu Aug  7 02:07:45 PDT 2008 -->

Any ideas how to get it to work directly from the bookmarks?

Share Improve this question edited Jan 18, 2019 at 8:01 Ijas Ameenudeen 9,2594 gold badges44 silver badges55 bronze badges asked Aug 7, 2008 at 9:08 svristsvrist 7,1107 gold badges46 silver badges67 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 4

Can you sniff the traffic to find what's actually being sent? Is it sending any auth data at all and it's incorrect or being presented in a form the server doesn't like, or is it never being sent by firefox at all?

@travis Looks very nice! I will sure take a look into it. I can think of several places I can use that

I never got round to sniff the traffic but found out that a php site on my own server with http-auth worked fine, so i figured it was something with delicious. I then created a php page that does a wget of the delicious api and everything works fine :)

Does calling the method twice work?

Seems to me that your authentication is being approved after the content arrives, so then a second attempt now works because you have the correct cookies.

I'd remend checking out the iMacros addon for Firefox. I use it to login to a local web server and after logging in, navigate directly to a certain page. The code I have looks like this, but it allows you to record your own macros:

VERSION BUILD=6000814 RECORDER=FX
TAB T=1
URL GOTO=http://10.20.2.4/login
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:introduce ATTR=NAME:initials CONTENT=username-goes-here
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=NAME:introduce ATTR=NAME:password CONTENT=password-goes-here
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:introduce ATTR=NAME:Submit&&VALUE:Go
URL GOTO=http://10.20.2.4/timecard

I middle click on it and it opens a new tab and runs the macro taking me directly to the page I want, logged in with the account I specified.

发布评论

评论列表(0)

  1. 暂无评论