Timeline Twitter com php
Opa! post rápido.. apenas para registrar por aqui, uma forma de recuperar a timeline de algum usuário do Twitter. Mas dessa vez, sem usar funções como: file_get_contents(), fopen(), simplexml_load_file().. pois essas precisam de uma configuração que geralmente vem desativada em servidores compartilhados.
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/storage/blablablabla.php on line n
Logo, vamos usar cURL:
<?php function curl_file($url, $timeout=0){ $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $url ); //curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, $timeout ); $content = curl_exec( $ch ); curl_close( $ch ); return $content; } $url = 'http://twitter.com/statuses/user_timeline/tiu_uiLL.rss?count=1'; $xml = new SimpleXMLElement( curl_file( $url ) ); $item = $xml->channel->item; var_dump( $item ); ?>
=) é isso ai.