> XHTML 1.0 Transitional Invalid_ 

c u t u p @ c u t u p . o r g

 xml 

[del.icio.us bookmarklet php] last modified: 03/25/2007 02:06 pm

Well, John Ressig's excellent del.icio.us super-fast bookmarklet stopped working a while ago when delicious changed their posting method. It used to allow one click transparent posting to del.icio.us - now it leaves you on the posting page with an error message 'A required security token was not received with your form data.', albeit with all the fields nicely filled in, and you have to manually hit post. The horror!

But I'm proud to say I've managed to cobble something together that works the way it used to. It's a bit more complicated though, and requires your own web space (localhost works if you're running a web server on your own machine).

It's a php script that generates a bookmarklet that works just like the old one did. However, instead of sending the information straight to delicious, it sends its information to the script, and the script uses the del.icio.us API to post the item.

The script lives here. Put it in a web accessible directory, fill in the username, password, and (optional) default_tags, then visit the script in your browser for instructions. It's a very good idea to use .htaccess to protect the script from anyone else, otherwise whoever has the bookmarklet can post to your account.

There are some things I don't like about the script.

I'll keep working on some improvements, but for now it at least works.

UPDATE:

This is now rendered useless (and thats a good thing) by the following bookmarklet code. It submits direct to the api, will prompt for user:pass the first time you submit in a session, and automatically closes the post acknowledgment tab, which the whole point of the php script was to avoid. Here you go:

javascript:e=%22%22+(window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);void(delicious = open('https://api.del.icio.us/v1/posts/add?description='+encodeURIComponent(document.title)+'&extended='+escape(e).replace(/ /g, %22+%22)+'&tags=%s'+'&url='+window.location.href,'delicious','toolbar=no,width=500,height=150'), setTimeout('delicious.close()',5000))

create a bookmark with that as the location, assign a keyword, and then typing keyword tag1 tag2 ... in the url bar will submit that page to delicious, with any highlighted text on the page submitted as extended.




[php ical] last modified: 03/25/2007 02:04 pm

You can publish iCal calendars to a web page, and I wanted to be able to check it online. But it's not published in a very human-friendly way. So I wrote this little php script. Your published iCal calendar auto-updates, and then this script parses it and displays future events with date, and time (if present). For today's events, it even replaces the date with "TODAY."

It used to have some more frills, but when I started calling this script and displaying it on my desktop with Geektool, I took them all away.

So here's the script:

php_ical

It will look something like this.

THINGS I WANT TO DO: Support multiple calendars at once. Every time I try to do this, the script breaks.

NOTES: I use curl to get the published calendar into the script, since I use this on a Dreamhost account, and they have disabled filegetcontents(). Many people don't have curl compiled into php, so if you get a curl error, try replacing the part of the script from:

$ch = curl_init();

to curl_close($ch);

with:

$file = file_get_contents("$calendar");

and it should work.




[metafilter php] last modified: 03/25/2007 02:04 pm

If you want one of these cool things that I have, a button that attempts to ascertain if MEFIUP.png or MEFIDOWN.png , here's the code I used:

$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://www.metafilter.com');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt ($ch, CURLOPT_USERAGENT, $_ENV['HTTP_USER_AGENT']);
$file = curl_exec($ch);
curl_close($ch);
if (ereg("MetaTalk", $file)) {
 print "path_to_MEFIUP.png";
 die;
}
print "path_to_MEFIDOWN.png";

if you're on a server that allows filegetcontents() and/or doesn't have curl you can just do this:

$file = file_get_contents("http://metafilter.com");
if (ereg("MetaTalk", $file)) {
 print "path_to_MEFIUP.png";
 die;
}
print "path_to_MEFIDOWN.png";

You can grab the .pngs from up there and it needs to be in a php file, between php tags. And you need to replace the path_to_png parts with valid urls.

As you can see, the way it works is if I can see the word MetaTalk on mefi front page, I assume the site is up.

Heh.




[All Posts] [top]

tags:

bookmarklet
del.icio.us
ical
metafilter
php