# 1-Click TinyUrl + Twitter

2008-03-10

so me friends [@ashafrir](http://twitter.com/ashafrir) and [@jeffpulver](http://twitter.com/jeffpulver) got me onto twitter a few weeks ago. it's not hard to notice that everyone and his sister are using tinyurl to, well, tinyurl. the task is tedious (if you're as lazy as i am) you really want these things to take 1-click.

10 minutes of searching and 10 minutes of hacking later, [zvitz](javascript:\(function\(\)\{var%20z=open\(\).document;z.location=%22http://ohadpr.com/zvitz.php?url=%22+document.location;z.close\(\);\}\)\(\)) (sorta hebrew for twitt) is born. just **drag it to your toolbar**, and whenever you are on a page you would like to twit about, hit the bookmarklet, and you will find yourself in twitter, with your status already containing a tinyurl of the page you were looking at.

![](http://bp3.blogger.com/_pP-oC_-3Kb0/R9XF3Z4v45I/AAAAAAAAACM/riS0MRI0zrk/s400/Untitled-1.png)

here's the formatted source for the bookmarklet:

```javascript
javascript:
(function(){
  var z=open().document;
  z.location="http://ohadpr.com/zvitz.php?url="+document.location;
  z.close();
}
)()
```

and here's the PHP backend to support it:

```php
$f = @fopen('http://tinyurl.com/api-create.php?url=' . $_GET['url'], 'r') or header("Location: sorry zvit or tinyurl not working");
$tinyUrl = fgets($f, 8192);
fclose($f);
header("Location: http://twitter.com/home?status=$tinyUrl");
```
