In the same way as most other users do, I find myself frequently posting links on twitter using one of the many URL shortening services. I’ll say at this point that I absolutely loathe these services, the recent demise of Tr.im and the debacle which has followed enforces the view that replicating something which already exists is bound to lead to issues (the thinking behind the popular programming acronym DRY).
It would be a serious step forwards (IMHO), if twitter allowed you to convert sections of a tweet to a link in much the same way as one does in HTML so we can avoid this, but anyway, I’ve digressed, people might complain it would make it too “complicated”, rant over, back on track.
As the subject of this post suggests this is just a random little code snippet I put together today to help me hold onto my links, make them a little more searchable and use the real link not a shortened version by posting them to delicious when I tweet them. It almost certainly exists elsewhere, but this is my take on it and doesn’t rely on me using a particular browser and having a plug-in installed on all the machines I use it on which the otherwise excellent tweecious would do.
- PHP5 webserver
- SimplePie Rss parser (I’m using version 1.1.3 nothing has changed since which would break this, AFAIK)
- CRONtab or similar to make it automatic, you can always just load the page up in a browser window if you don’t have CRON on your server or use webcron.
What it does
- Any link you post on twitter is resolved to its original address, title grabbed off the original site and posted onto your delicious account with your tweet in the description and any tags you want.
- Links will only be posted once, so if a link is automatically posted and you then delete it from delicious then its not going to reappear the next time the script is run.
- You can optionally blacklist domains or sections of domains which you don’t want to be saved, for instance I tweeted a link to a programme on BBC iPlayer, there’s no point me saving it as iPlayer only stores stuff for a couple of weeks
- You can also prevent a tweet which has a specific hashtag from being posted, I use the tag “#ns” which will prompt the script to ignore the rest
To use it, just upload twittodel.php from the zip file below (or copy and paste the below source) to your webserver, add simplepie.inc and any other bits it needs, make a cache folder according to whatever you’ve set theÂ CACHE_DIR option to (as a default it wants a folder called ‘cache’.
As I say, it was put together fairly quickly so is not guaranteed to be perfect but anyway. Comments/improvements/criticism welcome. It might see the addition of Zemanta style automatic tagging like tweecious, I’ll update this post if it does.