Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 6.22 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <Window x:Class="MainWindow"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    Title="MainWindow" Height="410" Width="732">
  2.     <Grid Background="#FFA6C3F5" OpacityMask="#FF2271F2" Width="689">
  3.         <TextBox Height="23" HorizontalAlignment="Left" Margin="193,42,0,0" Name="txtinput" VerticalAlignment="Top" Width="180" Text="" BorderBrush="#FFE6EB2D" />
  4.         <Button Content="show" Height="28" HorizontalAlignment="Right" Margin="0,40,202,0" Name="btnshowresult" VerticalAlignment="Top" Width="88" Foreground="#FF1510B5">
  5.             <Button.BorderBrush>
  6.                 <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
  7.                     <GradientStop Color="Black" Offset="0" />
  8.                     <GradientStop Color="#FF22F4DC" Offset="1" />
  9.                 </LinearGradientBrush>
  10.             </Button.BorderBrush>
  11.         </Button>
  12.         <ListBox HorizontalAlignment="Left" Margin="410,93,0,34" Name="lsttweets" Width="263" OpacityMask="#FF908D8D" BorderBrush="#FFECF13B">
  13.             <ListBox.Foreground>
  14.                 <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
  15.                     <GradientStop Color="Black" Offset="0" />
  16.                     <GradientStop Color="#FFE71E1E" Offset="1" />
  17.                 </LinearGradientBrush>
  18.             </ListBox.Foreground>
  19.         </ListBox>
  20.         <Label Content="User Name /Iinput" Height="28" HorizontalAlignment="Left" Margin="70,40,0,0" Name="lblinput" VerticalAlignment="Top" Width="117" Foreground="#FF2042E4" Visibility="Visible" />
  21.         <ListBox Margin="0,127,440,69" Name="lstmentions" HorizontalAlignment="Right" Width="109" BorderBrush="#FFEFF429">
  22.             <ListBox.Foreground>
  23.                 <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
  24.                     <GradientStop Color="Black" Offset="0" />
  25.                     <GradientStop Color="#FFC318ED" Offset="1" />
  26.                 </LinearGradientBrush>
  27.             </ListBox.Foreground>
  28.         </ListBox>
  29.         <ListBox HorizontalAlignment="Right" Margin="0,127,305,69" Name="lsthashtags" Width="110" BorderBrush="#FFEFF435">
  30.             <ListBox.Foreground>
  31.                 <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
  32.                     <GradientStop Color="Black" Offset="0" />
  33.                     <GradientStop Color="#FFFAD013" Offset="1" />
  34.                 </LinearGradientBrush>
  35.             </ListBox.Foreground>
  36.         </ListBox>
  37.         <Label Content="Tweets" Height="28" HorizontalAlignment="Left" Margin="528,59,0,0" Name="Label1" VerticalAlignment="Top" Width="54" Foreground="#FF1A34DF" />
  38.         <ListBox Height="175" HorizontalAlignment="Left" Margin="12,127,0,0" Name="ListBox1" VerticalAlignment="Top" Width="108" BorderBrush="#FFECF141">
  39.             <ListBox.Foreground>
  40.                 <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
  41.                     <GradientStop Color="Black" Offset="0" />
  42.                     <GradientStop Color="#FF73E214" Offset="1" />
  43.                 </LinearGradientBrush>
  44.             </ListBox.Foreground>
  45.         </ListBox>
  46.         <Label Content="Hashtags" Height="28" HorizontalAlignment="Right" Margin="0,93,335,0" Name="Label2" VerticalAlignment="Top" Foreground="#FF2E48EE" />
  47.         <Label Content="Mentions" Height="28" HorizontalAlignment="Left" Margin="169,93,0,0" Name="Label3" VerticalAlignment="Top" Width="54" Foreground="#FF1532EE" />
  48.         <Label Content="Mentions & Hashtags" Height="28" HorizontalAlignment="Left" Margin="12,93,0,0" Name="Label4" VerticalAlignment="Top" Width="108" Foreground="#FF1E3AE8" />
  49.         <Label Height="28" HorizontalAlignment="Right" Margin="0,317,316,0" Name="Label5" VerticalAlignment="Top" Width="79" Foreground="#FFC11111" Background="#FFBDD5F2" />
  50.         <Label Height="28" HorizontalAlignment="Left" Margin="154,317,0,0" Name="Label6" VerticalAlignment="Top" Width="77" Background="#FFB9D4F5" />
  51.         <Label Content="Twitter" Height="26" HorizontalAlignment="Left" Margin="311,0,0,0" Name="Label7" VerticalAlignment="Top" Width="52" FontWeight="Bold" FontStyle="Italic" FontStretch="Expanded" Foreground="#FFEBF10F"></Label>
  52.     </Grid>
  53. </Window>
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. 'Copy all imports
  62. Imports System.Net
  63. Imports System.IO
  64. Imports System.Xml
  65. Class MainWindow
  66.  
  67.     'Copy this function
  68.     'Function takes username as a string and page number
  69.     'and returns a list containing the last 50 tweets
  70.     'made by the user
  71.     'Page is the page number containing the tweets and starting
  72.     'with 1, to get more tweets you simply get page 2, then 3 ..etc
  73.     Function getTweets(ByVal username As String, ByVal page As Integer) As List(Of String)
  74.         Dim URL = "http://api.twitter.com/statuses/user_timeline/" & username & ".xml?count=50&page=" & page
  75.         Dim tweets As New List(Of String)
  76.         Dim Request As HttpWebRequest = HttpWebRequest.Create(URL)
  77.         Request.Method = "GET"
  78.         Dim Response As WebResponse = Request.GetResponse
  79.         Dim Reader As New StreamReader(Response.GetResponseStream)
  80.         Dim Results As String = Reader.ReadToEnd
  81.         Reader.Close()
  82.         Response.Close()
  83.  
  84.         Dim Doc As New XmlDocument
  85.         Doc.LoadXml(Results)
  86.         Dim XMLNodes As XmlNodeList = _
  87.            Doc.SelectNodes("//statuses/status/text")
  88.         For Each Node As XmlNode In XMLNodes
  89.             tweets.Add(Node.InnerText)
  90.         Next
  91.         Return tweets
  92.     End Function
  93.  
  94.  
  95.     Private Sub btnshowresult_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnshowresult.Click
  96.  
  97.  
  98.         Dim username As String = txtinput.Text
  99.  
  100.  
  101.         Dim tweet1 As List(Of String) = getTweets(username, 1)
  102.         Dim tweet2 As List(Of String) = getTweets(username, 2)
  103.  
  104.  
  105.         For Each t In tweet1
  106.             lsttweets.Items.Add(t & ControlChars.NewLine)
  107.  
  108.         Next
  109.  
  110.         For Each t In tweet2
  111.             lsttweets.Items.Add(t & ControlChars.NewLine)
  112.  
  113.  
  114.             For Each tweet In t.Split
  115.                 If tweet.Contains("#") Then
  116.                     lsthashtags.Items.Add(t)
  117.  
  118.                 End If
  119.             Next
  120.  
  121.  
  122.             For Each twt In t.Split
  123.                 If twt.Contains("@") Then
  124.                     lstmentions.Items.Add(t)
  125.  
  126.                 End If
  127.             Next
  128.  
  129.         Next
  130.  
  131.  
  132.  
  133.     End Sub
  134.  
  135.  
  136.  
  137. End Class