title: Filtering and processing url from tweets
body: <p>I am processing tweets and collecting URLs from the tweets.</p>
  
  <ol>
  <li>If url stands for twitter(i.e. starts with <code>t.com</code> or <code>twitter.com</code>) then skip it</li>
  <li>If that url in the tweets is short url, then I convert it to long url.</li>
  </ol>
  
  <p>CODE:</p>
  
  <pre><code>        if(preg_match($reg_exUrl, $tweet, $url)) {
                  preg_match_all($reg_exUrl, $tweet, $urls);
                  foreach ($urls[0] as $url) {
                  echo "Tiny url :  {$url}&lt;br&gt;";
                  $full = MyURLDecode($url);
                  echo "Full url : $full&lt;br&gt;";
                  if (strpos($full, '//t.co') === true)                   
                      continue;   
                  if (strpos($full, '//twitter.com') === true)                    
                  continue;
                  else if (strpos($full, '//bit.ly') !== true)                    
                      $full = MyURLDecode($full);
                  $url_count = get_twitter_url_count($full);
                  echo "Url count: $url_count";               
                  //echo "Numbers of tweets containing this link : ", $code['count'];
                  echo "&lt;br&gt;";
                  }
              } else {
              echo "Mismatch&lt;br&gt;";        
      }           
  function MyURLDecode($url)     
      {    
          $ch = @curl_init($url);    
          @curl_setopt($ch, CURLOPT_HEADER, TRUE);    
          @curl_setopt($ch, CURLOPT_NOBODY, TRUE);    
          @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);    
          @curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);    
          $url_resp = @curl_exec($ch);    
          preg_match('/Location:\s+(.*)\n/i', $url_resp, $i);    
          if (!isset($i[1]))    
          {
  
          return $url;    
          }    
          return $i[1];    
      } 
  
   function get_twitter_url_count($url) {    
              $encoded_url = urlencode($url);    
              $content = @file_get_contents('http://urls.api.twitter.com/1/urls/count.json?url=' . $encoded_url);    
              return $content ? json_decode($content)-&gt;count : 0;   
          }
  </code></pre>
  
  <p>Problem with this is:</p>
  
  <ol>
  <li>It does not skip twitter URL</li>
  <li>Some case long url are again short url, which need to be transformed to long url. But it fails here</li>
  </ol>