Windows Phone 8 - Twitter API [英] Windows Phone 8 - Twitter API
问题描述
我正在做一些研究,但似乎无法找到一种明确的方法来查询 Twitter 的 API 以使用 C# 在 WP8 上获取用户的推文.
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.
因此我需要对自己/我的应用进行身份验证吗?TweetSharp
库是否适合我的目标?
Do I therefore need to Authenticate myself/my app? Is the TweetSharp
library appropriate for my objective?
推荐答案
我使用了以下示例 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.");
}
我在 twitter 开发网站上创建了一个新的应用程序用户:https://dev.twitter.com/user/login?destination=home.设置完成后,我基本上复制并粘贴了 AuthenticateWith
和 TwitterService
方法中的密钥.
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.
这篇关于Windows Phone 8 - Twitter API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!