Http Auth in a Firefox bookmarklet
I'm trying to create a bookmarklet for posting del_icio_us bookmarks to a separate account.
I tested it from the command line like:
wget -O - --no-check-certificate \
"https_seconduser:thepassword@api_del_icio_us/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:password@api_del_icio_us/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_net uncompressed/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_net uncompressed/chunked Thu Aug 7 02:07:45 PDT 2008 -->
Any ideas how to get it to work directly from the bookmarks?
4 Answers
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?
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 recommend 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.
How can I turn a string of HTML into a DOM object in a FF extension?
I'm downloading a web page (tag soup HTML) with XMLHttpRequest and I want to take the output and turn it into a DOM object that I can then run XPATH queries on. How do I convert from a string into DOM object? It appears that the general solution is to create a hidden iframe and throw the contents of the string into that. There has been talk of updating DOMParser to support text/html but as of Firefox 3.0.1 you still get an NS_ERROR_NOT_IMPLEMENTED if you try. Is there any option besides using the hidden iframe trick? And if not, what is the best way to do the iframe trick so that your code works outside the context of any currently open tabs (so that closing tabs won't screw up the code, etc)? This is an example of why I'm looking for a solution other than the iframe hack, if I have to write all that code to have a robust solution, then I'd rather keep looking for something else…
Call ASP . NET function from JavaScript?
I'm writing a web page in ASP . NET. I have some JavaScript code, and I have a submit button with a click event. Is it possible to call a method I created in ASP with JavaScript's click event? You should be using some Ajax library like : Anthem 20 Answers Well, if you don't want to do it using Ajax or any other way and just want a normal ASP . NET postback to happen, here is how you do it (without using any other libraries): It is a little tricky though... :) i. In your code file (assuming you are using C# and .NET 2.0 or later) add the following Interface to your Page class to make it look like public partial…
JavaScript Troubleshooting Tools in Internet Explorer
I use Firebug and the Mozilla JS console heavily, but every now and then I run into an IE-only JavaScript bug, which is really hard to locate (ex: error on line 724, when the source HTML only has 200 lines). I would love to have a lightweight JS tool (a la firebug) for Internet Explorer, something I can install in seconds on a client's PC if I run into an error and then uninstall. Some Microsoft tools take some serious download…