twitter - LinqToTwitter issue connecting with the API in ASP.NET Webforms -
i've been using linqtotwitter have incorporated couple of sites. 1 site giving me headache though. appears authenticate seek , iterate on collection of tweets returned error:
"an existing connection forcibly closed remote host"
here code:
protected void page_load(object sender, eventargs e) { var auth = new singleuserauthorizer { credentialstore = new singleuserinmemorycredentialstore { consumerkey = system.configuration.configurationmanager.appsettings["twitterapikey"], consumersecret = system.configuration.configurationmanager.appsettings["twittersecretkey"], accesstoken = system.configuration.configurationmanager.appsettings["twitteraccesstoken"], accesstokensecret = system.configuration.configurationmanager.appsettings["twittersecrettoken"] } }; var ctx = new twittercontext(auth); var mytweets = ctx.status.where(t => t.type == statustype.user && t.screenname == "paulpitchford"); seek { if (mytweets != null) { foreach (var item in mytweets) { tweets.tweetlist.add(tweetparser.parsetweet(item.text)); } } } grab (exception err) { } }
the error occurs hits line: foreach (var item in mytweets)
the keys match api given keys , can't see i'm doing much wrong. can suggest may going wrong?
thank you.
paul.
linq twitter async. means need materialize query before going foreach loop, this:
var mytweets = await ctx.status.where( t => t.type == statustype.user && t.screenname == "paulpitchford") .tolistasync();
notice await on query , tolistasync operator. also, must add together async modifier page_load, this:
protected async void page_load(object sender, eventargs e)
asp.net twitter linq-to-twitter
No comments:
Post a Comment