Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Recupera postagens de usuários do Twitter
- * @param string $user O nome do usuário
- * @return &array Matriz contendo as postagens do membro
- */
- function &getTwitterPostsByUser( $user ){
- $arr = array();
- $cur = null;
- $xml = new XMLReader( );
- if ( $xml->open( sprintf( 'http://twitter.com/statuses/user_timeline/%s.xml' , $user ) ) ){
- while ( $xml->read() ){
- if ( $xml->nodeType == XMLReader::ELEMENT ){
- $node = $xml->localName;
- if ( $xml->read() ){
- switch ( $node ){
- case 'created_at' :
- $cur = strtotime( $xml->value );
- break;
- case 'text' :
- $arr[ $cur ] = preg_replace( '/@([a-zA-Z_]+)/' , '<a href="http://twitter.com/$1">@$1</a>' , $xml->value );
- break;
- }
- }
- }
- }
- $xml->close();
- ksort( $arr );
- } else
- throw new Exception( 'Não foi possível abrir o documento.' );
- return $arr;
- }
Advertisement
Add Comment
Please, Sign In to add comment