【发布时间】:2012-02-06 08:28:05
【问题描述】:
任何关于在 iOS 5 中使用 Twitter 框架的入门资料,我打算查看来自用户的推文
【问题讨论】:
-
这个问题有什么问题吗?
任何关于在 iOS 5 中使用 Twitter 框架的入门资料,我打算查看来自用户的推文
【问题讨论】:
苹果最新发布的Twitter框架,可以参考文档
对于示例源代码
此示例演示了内置的 Twitter 组合表、创建 POST 请求以及解析返回的数据。
【讨论】:
这是您在 .NET 中所需的模型。我相信你可以将它翻译成 Objective-c,或者你正在使用的任何东西。基本上,XML 文件就是你所需要的。
string userName;
WebClient client;
XDocument document;
ObservableCollection<Tweet> tweetList;
tweetList = new ObservableCollection<Tweet>();
client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri("http://twitter.com/statuses/user_timeline/" + userName + ".xml"));
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
document = XDocument.Parse(e.Result);
foreach (XElement tweet in document.Descendants("status"))
{
Tweet temp = new Tweet();
temp.Name = tweet.Element("user").Element("name").Value;
temp.Image = tweet.Element("user").Element("profile_image_url").Value;
temp.Text = tweet.Element("text").Value;
temp.Date = tweet.Element("created_at").Value.Substring(0, 11);
tweetList.Add(temp);
}
}
}
【讨论】: