Here I am getting url from tweets, converting that url to long url.
And then getting count value for numbers of tweets containing that url.
$reg_exUrl = "/(?<![\>https?:\/\/|href=\"'])(?<http>(https?:[\/][\/]|www\.)([a-z]|[A-Z]|[0-9]|[\/.]|[~])*)/";
// The Text you want to filter for urls
$text = "Make this Xmas super powerful with #Krrish3 on http://t.co/PHOdAqnzkT !\ ";
// Check if there is a url in the text
if(preg_match($reg_exUrl, $text, $url)) {
preg_match_all($reg_exUrl, $text, $urls);
foreach ($urls[0] as $url) {
echo "{$url}<br>";
$full = MyURLDecode($url);
echo "full is: $full<br>";
$feedUrl = "http://urls.api.twitter.com/1/urls/count.json?url=$full";
$json = file_get_contents($feedUrl);
$code = json_decode($json,true);
var_dump($code);
echo "1";
echo "Numbers of tweets containing this link : ", $code['count'];
echo "2";
}
} else {
echo $text;
}
Issues:
1. Decoding some twitter tiny urls again give biturl(i.e. again tiny url)
2. Getting number of tweets(count value) containig that url. Above code give it, but for most of url it show 0 though they have count value
Any suggestion for improvement?