Get latest tweet using Tweetsharp on Windows Phone 7

后端 未结 1 539
温柔的废话
温柔的废话 2021-01-23 07:15

I only want to get a latest tweet to my Windows Phone Apps using Tweetsharp. below is what I have done:

  1. Installing Tweetsharp using Nuget Package Manager.
1条回答
  •  迷失自我
    2021-01-23 08:01

    The documentation for tweetsharp is available on the wiki.

    The best method is statuses/user_timeline :

    Returns a collection of the most recent Tweets posted by the user indicated by the screen_name or user_id parameters

    You have all the prerequisites. Let's code !

    A piece of Xaml

    
    
        
            
                
                    
                        
                        
                    
                    
                    
                
            
        
        
        
        
    
    

    and a piece of C#

    // Constructor
    public MainPage()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    }
    
    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        var service = new TwitterService("yourconsumerKey", "yourconsumerSecret");
        service.AuthenticateWith("youraccessToken", "youraccessTokenSecret");
    
        service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions() { ScreenName = "SCREENNAME" }, (ts, rep) =>
            {
                if (rep.StatusCode == HttpStatusCode.OK)
                {
                    //bind
                    this.Dispatcher.BeginInvoke(() => { tweetList.ItemsSource = ts; });
                }
            });
    }
    

    that's all !

    0 讨论(0)
提交回复
热议问题