2011-05-27 80 views

回答

8
 
function getTweetCount($url) 
{ 
    $url = urlencode($url); 
    $twitterEndpoint = "http://urls.api.twitter.com/1/urls/count.json?url=%s"; 
    $fileData = file_get_contents(sprintf($twitterEndpoint, $url)); 
    $json = json_decode($fileData, true); 
    unset($fileData); // free memory 
    //print_r($json); 
    return $json['count']; 
} 
+1

我可以知道爲什麼我們需要釋放內存嗎? – 2012-05-10 01:59:40

+2

@WhateverKitchen你沒有。 – gabrielk 2013-01-05 03:38:26