0
Sociable and TinyURL
After installing a great little plugin called Sociable (to show the “Share and Enjoy” options you see at the bottom of my posts), I still needed something to auto-magically create a short url to post where character space is limited – places like Twitter.
After seeing a post from @briancray on how to Generate TinyURLs With 1 Line Of PHP, I had to give it a shot – and I give all the credit to Brian on this.
Here is the finished product. Just plug the following code in your Sociable plugin just above the ‘sociable_known_sites’ Array and don’t forget to also update the URL for the Twitter (or any other) variable in its array.
// -- Create TinyURL for Twitter -- //
$newShortURL = file_get_contents('http://tinyurl.com/api-create.php?url=' . urlencode('http://'.$_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI']));
$newTwitterURL = "http://twitter.com/home?status=Reading @YourUserNameHere TITLE ".$newShortURL;
// -- End TinyURL for Twitter -- //
There you have it. Enjoy!
If you’re not already, follow me on twitter!







