简体   繁体   中英

Windows Phone 8 - Twitter API

I am doing some research and can't seem to find a definitive way to query Twitter's API to get a user's tweets on WP8 using C#.

The twitter user isn't my own account and all I want to do is retrieve tweets and not post any tweets.

Do I therefore need to Authenticate myself/my app? Is the TweetSharp library appropriate for my objective?

I used the following example http://code.msdn.microsoft.com/wpapps/Twitter-Sample-using-f36bab75 :

if (NetworkInterface.GetIsNetworkAvailable())
{
    //Obtain keys by registering your app on https://dev.twitter.com/apps
    var service = new TwitterService("abc", "abc");
    service.AuthenticateWith("abc", "abc");

    //ScreenName is the profile name of the twitter user.
    service.ListTweetsOnUserTimeline(new ListTweetsOnUserTimelineOptions() { ScreenName = "the_appfactory" }, (ts, rep) =>
    {
        if (rep.StatusCode == HttpStatusCode.OK)
        {
            //bind
            this.Dispatcher.BeginInvoke(() => { tweetList.ItemsSource = ts; });
        }
    });
}
else
{

    MessageBox.Show("Please check your internet connestion.");
}

I created a new application user the twitter dev website: https://dev.twitter.com/user/login?destination=home . Once this was set-up, I essentially copied and pasted the keys within the AuthenticateWith and TwitterService methods.

I haven't solved exactly how I shall display the data but, at runtime, I can see data being passed in.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM