问题描述
我想读取用户的公共Twitter的状态,所以我可以在我的Windows Phone应用程序显示出来。
I'm trying to read the public twitter status of a user so I can display it in my Windows Phone application.
我使用的是斯科特谷的例子:http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx
I'm using Scott Gu's example:http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx
在我的code回来的异步调用,我得到一个System.Security.SecurityException当我尝试使用e.Result。
When my code comes back from the async call, I get a "System.Security.SecurityException" as soon as I try to use the e.Result.
我知道我的URI是正确的,因为我可以扑通它在浏览器中,并获得了较好的效果。
I know my uri is correct because I can plop it in the browser and get good results.
下面是我的relavent code:
Here is my relavent code:
public void LoadNewsLine()
{
WebClient twitter = new WebClient();
twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
twitter.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=krashlander"));
}
void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
XElement xmlTweets = XElement.Parse(e.Result); //exception thrown here!
var message = from tweet in xmlTweets.Descendants("status")
select tweet.Element("text").Value;
//Set message and tell UI to update.
//NewsLine = message.ToString();
//RaisePropertyChanged("NewsLine");
}
任何想法吗?
Any ideas anyone?
解决方案:我终于想通这一个。我只是忘了取消注释的: 能力在WMAppManifest.xml。有一次,我做到了安全异常走。的
SOLUTION:I finally figured this one out. I had simply forgotten to uncomment the: capability in the WMAppManifest.xml.Once I did that the security exception went away.
推荐答案
我终于想通这一个。我只是忘了取消注释的:
I finally figured this one out. I had simply forgotten to uncomment the:
<Capability Name="ID_CAP_NETWORKING"/>
在WMAppManifest.xml能力。有一次,我做到了安全异常走。
capability in the WMAppManifest.xml. Once I did that the security exception went away.
这篇关于如何阅读使用。NET公共Twitter的饲料(在Windows Phone)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!