2011-05-23 47 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

相關問題