I recently switched from Google Reader to Fever°. I am happy I switched, but I quickly missed the ease with which I could save articles to Instapaper. The Instapaper bookmarklet has some way of divining which article you’re focused on in Google Reader, so you can add the article right from the feed page, instead of opening the article itself, then adding it to Instapaper. It’s very convenient, and fast.

Fever° also has Instapaper support, but it works a little differently. When focused on an article, you tap i to open a new window containing a pre-filled Instapaper form, then click the Add button. The item is added, and you’re left with a window showing your Instapaper unread items.

That’s not bad, but I didn’t want that window hanging around. I had to wait for it to load, then get rid of it. I had to take my hand off the keyboard to click the Add button. It worked, but was less graceful than what I had before.

I spent a few minutes with PHP and came up with a solution. It’s not as pretty as what I had with Google Reader, but it’s just as fast, and works without any mousing, clicking, or lingering windows. I tap ion an article, and a window pops up, says ‘Saved,’ and disappears on its own after a second or so. (If there’s a problem, you see an error instead and the window does not go away.)

First, create a script on your site. I named mine instapaper.php and put it at the root of my Fever° site. But you can put it anywhere, including on another domain entirely. You just need to know the URL to configure Fever° later.

<?php

$api = 'https://www.instapaper.com/api/add';
$close_timer = 750; // how many ms to display 'Saved!'

// Your instapaper.com credentials
$user = 'my_username';
$pass = 'my_password';

$u = urlencode($_GET['url']);
$t = urlencode($_GET['title']);
$s = urlencode($_GET['selection');

$curl_url = "$api?username=$user&password=$pass&url=$u&title=$t&selection=$s";

$ch = curl_init($curl_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$ret = curl_exec($ch);
curl_close($ch);

if ($ret == '201'):
?>

<h2>Saved!</h2>
<script language="javascript">
setTimeout("self.close();",<?php echo $close_timer ?>)
</script>

<?php else: ?>

<p>ERROR: instead of response code 201, we got:<br />
<?php echo $ret ?></p>

<?php endif ?>

Now, go into your Fever° preferences and click the Sharing tab. I suggest removing the i key from the Instapaper item, and changing its name (I used ‘ORIGINAL Instapaper’). That way it’s still there if you ever want to switch back.

Click the + icon to add a new service. Name it ‘Instapaper,’ set the key to i or whatever you prefer, and set the URL as follows. You’ll need to substitute the path to your script.

http://mysite.com/fever/instapaper.php?url=%u&title=%t&selection=%e

Click Save and you’re done.

(I’ll write more about Fever° itself after I’ve used it for a while longer.)