开发者

Getting Null Pointer Exception in Twitter API consumption in .net

I am developing a .net based application to consume Twitter API.I am getting the following error:

System.NullReferenceException: Object reference not set to an instance of an object

Code is as follows

StringBuilder strB = new StringBuilder();
XmlReader reader = new XmlTextReader("http://twitter.com/statuses/public_timeline.xml");
try
{
    while (reader.ReadToFollowing("user"))
    {
        strB.Append("z: " + reader.GetAttribute("id").ToString());
        strB.Append(" | Y: " + reader.GetAttribute("name").ToString());
        strB.Appen开发者_如何学Pythond(" | style: " + reader.GetAttribute("style").ToString());
     }
}
catch (Exception ex) 
{ 
     Response.Write(ex.ToString()); 
}
finally
{
    reader.Close();
}
Response.Write(strB.ToString());

Can anyone help me?

Thanks in advance Daman


Have you given a thought about using a third party client library ?

Here are some of the free alternatives

  • tweetsharp
  • linq to twitter


name, id, and style are tags, not attributes.
Therefore, GetAttribute returns null.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜