开发者

Read twitter user_timeline.xml?screen_name="xyz" file content in csharp

开发者 https://www.devze.com 2023-03-10 04:11 出处:网络
any can tell me the procedure (code ) to retrieve the ID and Message(text Tag) value in c# variable from the http://twitter.com/statuses/user_timeline.xml?screen_name=\"xyx\";

any can tell me the procedure (code ) to retrieve the ID and Message(text Tag) value in c# variable from the http://twitter.com/statuses/user_timeline.xml?screen_name="xyx"; UR开发者_运维知识库L in c#.


You could use code like this:

var url = "http://twitter.com/statuses/user_timeline.xml?screen_name=" + name;
var doc = XDocument.Load(url);
var statuses = from status in doc.Root.Elements("status")
               select new
               {
                   Id = status.Element("id").Value,
                   Text = status.Element("text").Value
               };


Link to Twitter is definitely an option.

Their code example:

var twitterCtx = new TwitterContext();

            var publicTweets =
                from tweet in twitterCtx.Status
                where tweet.Type == StatusType.Public
                select tweet;

            publicTweets.ToList().ForEach(
                tweet => Console.WriteLine(
                    "User Name: {0}, Tweet: {1}",
                    tweet.User.Name,
                    tweet.Text));

That said, i'm a big fan of Linq syntax.

0

精彩评论

暂无评论...
验证码 换一张
取 消