• Revista PROGRAMAR: Já está disponível a edição #53 da revista programar. Faz já o download aqui!

Sign in to follow this  
Followers 0

Obter as últimas mensagens do Twitter

1 post in this topic

Um pequeno script para obter as ultimas mensagens do teu http://www.twitter.com e dos teus amigos.

require 'rexml/document'
include REXML

def getStatuses(username,password)
    url = URI.parse('http://twitter.com/statuses/friends_timeline.xml')
    req = Net::HTTP::Get.new(url.path)
    res = Net::HTTP.start(url.host, url.port) {|http|

file = getStatuses('username','password')
xml = Document.new(file.body)

messages = []

xml.root.each_element('status') { |st| messages << st.elements['text'].text }

messages.each { |msg| puts msg }

Basta alterar o username e password para os vossos dados. Happy twittering  :)


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0