Created
May 11, 2011 09:43
-
-
Save yohfee/966203 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'mscorlib' | |
| require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' | |
| require 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' | |
| include System::Net | |
| include System::Text | |
| include System::Windows::Forms | |
| include System::Xml | |
| class MyForm < Form | |
| def initialize | |
| textbox = TextBox.new | |
| textbox.dock = DockStyle.Top | |
| textbox.text = "yohfee" | |
| button = Button.new | |
| button.dock = DockStyle.Top | |
| button.text = "Get timeline" | |
| listbox = ListBox.new | |
| listbox.dock = DockStyle.Fill | |
| self.controls << listbox << button << textbox | |
| button.click do | |
| listbox.items.clear | |
| account = textbox.text | |
| url = "http://twitter.com/statuses/user_timeline/#{account}.xml" | |
| client = WebClient.new | |
| client.encoding = Encoding.UTF8 | |
| data = client.download_data(url) | |
| result = Encoding.UTF8.get_string(data) | |
| doc = XmlDocument.new | |
| doc.load_xml(result) | |
| nodes = doc.select_nodes("//statuses/status/text") | |
| nodes.each{|node| listbox.items << node.inner_text} | |
| end | |
| end | |
| end | |
| Application.run MyForm.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment