2011-05-23 40 views

回答

1

你好 对不起,我不知道PHP那么好,而不是在所有的JQuery,然而,这里是我在C#中所做的...希望它有帮助;)

// Launch the request to obtain the number of followers of the user 
WebRequest request = HttpWebRequest.Create("http://twitter.com/users/show.xml?screen_name=[username]"); 

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) 
{ 
StreamReader streamReader = new StreamReader(response.GetResponseStream()); 

// Load response in an XML Document 
XmlDocument doc = new XmlDocument(); 
doc.LoadXml(streamReader.ReadToEnd()); 

// Parse the node we're interested in... 
XmlNode node = doc.DocumentElement.SelectSingleNode("followers_count"); 

// ... and affect the number of followers 
labelScore.Text = node.InnerText; 
} 
+0

谢谢,这非常有帮助。我也可以使用其他属性从xmldoc中提取。 – vizzaro 2011-05-25 15:36:29

1

是的,您可以使用users/show来获取此信息。你会发现它是一个名为followers_count属性:

"followers_count": 160752, 
+0

太棒了。我如何检索followers_count属性呢?你有一个简单的例子。赞赏。使用jQuery或PHP或任何你喜欢的。 – vizzaro 2011-05-23 15:55:43

相关问题