Thursday, 19 September 2013

How To Add Tweeting With Short URL Functionality To A Website (With PHP)

There is a 140 character limit in Twitter & the length of the URL is a headache. So, auto-shortening the URL with a short URL service will be handy.

The file_get_contents function of PHP helps us to easily get the short URL as a string. Lets use the TinyURLservice & create a simple function:
function makeShortURL($URLToConvert) { 
     $shortURL= file_get_contents("" . $URLToConvert); 
     return $shortURL; 
calling the function with the URL, like:
<?php echo makeShortURL("")?>


No comments:

Post a Comment