In questo tutorial imparerete come creare una semplice funzione per ottenere i vostri tweet. L’unico parametro obbligatorio che la funzione myTweet prende in ingresso è lo screen name. La funzione restituisce le informazioni essenziali, se invece desiderate tutte le informazioni comprese anche quelle meno utilizzate, dovete passare false al terzo parametro della funzione.

 
function myTweets($screenname, $count=5, $simple=TRUE) {
$url = "http://twitter.com/statuses/user_timeline.json?screen_name={$screenname}&count={$count}&include_rts=1";
$data = @file_get_contents($url);
if ($http_response_header[0] != ‘HTTP/1.0 200 OK’):
return FALSE;
endif;
$data = json_decode($data);
if ($simple == TRUE):
$out = array();
foreach ($data as $tweet):
$o = new stdClass;
$o->text = htmlentities($tweet->text, ENT_QUOTES, ‘UTF-8′, FALSE);
$o->id = $tweet->id_str;
$o->timestamp = strtotime($tweet->created_at);
$o->url = "https://twitter.com/#!/{$screenname}/status/{$tweet->id_str}";
$out[] = $o;
endforeach;
$data = $out;
endif;
return $data;
}
 
$tweets = myTweets(‘tuoscreename’, 2);
echo
‘, print_r($tweets);

fonte: www.sastgroup.com ? Vai al post originale