tellieno tellieno - 5 months ago 14
PHP Question

Tiny URL using PHP for auto-twitts

I'm trying to implement auto post on Twitter using PHP.

But because of twitt's character limit I wanted to know how can I use tinyURL, instead of placing the full link, like

You see it's quite long...

I know services like:



But how can I use these services in bulk, to generate hundreds of links every day with PHP?


You can check Google API, but I'm not sure about that much bulk. I can suggest 3 solutions for you:

  1. Create short links on your host using PHP.
  2. Twitter will shorten the URL for you if you tweet DIRECTLY. But, you cannot do it using auto-posting. So, count characters (like message + URL <= 140) and keep your automatic tweets length less than 140 characters.
  3. You can also try this (Check the PHP Source Code Example)

    function CompressURL($url) {
       $ch = curl_init();
       curl_setopt($ch, CURLOPT_URL, "http://"."".urlencode($url));
       curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
       curl_setopt($ch, CURLOPT_HEADER, 0);
       $shorturl = curl_exec ($ch);
       curl_close ($ch);
       return $shorturl;
    echo CompressURL(""); // Test