none
Display Twitter feed in form RRS feed

  • Question

  • I would like to add my twitter feed to my application in form1.

    How would I go about doing this?

    Saturday, January 1, 2011 8:29 AM

Answers

  • Twitter provides RSS feed of every account, provided account visibility is Public.

    If you are using New twitter, you'll have to find out your twitter feed link by

    1] either leave new twitter preview and find RSS links on right sidebar, or

    2] click on the RSS Feed icon in browser addressbar. It will probably show your favorites feed. Note the userid from URL.

        Now, use that userid in this fashion :

        http://twitter.com/statuses/user_timeline/userid .rss

     

    Once you get your twitter feed rss url, its simple to fetch entries.

    Sample code using my twitter feed :

    You'll need a RichTextBox and a Button on form. Keep default names.

    Public Class Form1
    
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
        Dim items As Xml.XmlNodeList = FetchTwitterFeed("http://twitter.com/statuses/user_timeline/14349915.rss")
    
        'Iterate and print each title
        For Each item As System.Xml.XmlNode In items
          RichTextBox1.AppendText(item.ChildNodes(0).InnerText & vbCrLf)
          'childNodes(0) gives title
          'for rest node indices like link,time etc
          'check source string
        Next
    
      End Sub
    
      Private Function FetchTwitterFeed(ByVal FeedUrl As String) As Xml.XmlNodeList
        Dim client As New System.Net.WebClient
        'get twitter feed in xml format
        Dim source As String = client.DownloadString(FeedUrl)
    
        'Check contents format if for reference
        'RichTextBox1.Text = source
    
        Dim doc As New System.Xml.XmlDocument()
        doc.LoadXml(source)
        'Select all the Items in node list
    
        Return doc.SelectNodes("//channel/item")
    
      End Function
    End Class
    

     

     

    -----------------

    For further development with twitter, check their developer portal.

    http://dev.twitter.com/

    Thanks

    A place for MSDN users to socialize 

    Living on Earth may be expensive, but did you know that it includes a free trip around the sun? Isn't that worth it?
    • Marked as answer by Liliane Teng Friday, January 7, 2011 7:24 AM
    Saturday, January 1, 2011 10:07 AM

All replies

  • Use HttpWebRequest to get the stuff on the website, and find

    <span
     class
    ="entry-content"
    >

    And then change label.text to the text within that.


    Striving to do my best.
    Saturday, January 1, 2011 9:07 AM
  • Twitter provides RSS feed of every account, provided account visibility is Public.

    If you are using New twitter, you'll have to find out your twitter feed link by

    1] either leave new twitter preview and find RSS links on right sidebar, or

    2] click on the RSS Feed icon in browser addressbar. It will probably show your favorites feed. Note the userid from URL.

        Now, use that userid in this fashion :

        http://twitter.com/statuses/user_timeline/userid .rss

     

    Once you get your twitter feed rss url, its simple to fetch entries.

    Sample code using my twitter feed :

    You'll need a RichTextBox and a Button on form. Keep default names.

    Public Class Form1
    
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
    
        Dim items As Xml.XmlNodeList = FetchTwitterFeed("http://twitter.com/statuses/user_timeline/14349915.rss")
    
        'Iterate and print each title
        For Each item As System.Xml.XmlNode In items
          RichTextBox1.AppendText(item.ChildNodes(0).InnerText & vbCrLf)
          'childNodes(0) gives title
          'for rest node indices like link,time etc
          'check source string
        Next
    
      End Sub
    
      Private Function FetchTwitterFeed(ByVal FeedUrl As String) As Xml.XmlNodeList
        Dim client As New System.Net.WebClient
        'get twitter feed in xml format
        Dim source As String = client.DownloadString(FeedUrl)
    
        'Check contents format if for reference
        'RichTextBox1.Text = source
    
        Dim doc As New System.Xml.XmlDocument()
        doc.LoadXml(source)
        'Select all the Items in node list
    
        Return doc.SelectNodes("//channel/item")
    
      End Function
    End Class
    

     

     

    -----------------

    For further development with twitter, check their developer portal.

    http://dev.twitter.com/

    Thanks

    A place for MSDN users to socialize 

    Living on Earth may be expensive, but did you know that it includes a free trip around the sun? Isn't that worth it?
    • Marked as answer by Liliane Teng Friday, January 7, 2011 7:24 AM
    Saturday, January 1, 2011 10:07 AM