I trying to create a Winforms app in VS for search a specific keyword and retrieve the tweet display in my app. Below is my code which trying to get 100 tweet from my profile and make a call to the new method in my form's constructor, followed by assignment of the data to the main tweets list box on my form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using LinqToTwitter;
public partial class Form1 : Form
{
private SingleUserAuthorizer authorizer =
new SingleUserAuthorizer
{
CredentialStore = new
SingleUserInMemoryCredentialStore
{
ConsumerKey ="",
ConsumerSecret ="",
AccessToken ="",
AccessTokenSecret =""
}
};
private List<Status> currentTweets;
public Form1()
{
InitializeComponent();
GetMostRecent100HomeTimeLine();
lstTweetList.Items.Clear();
currentTweets.ForEach(tweet =>
lstTweetList.Items.Add(tweet.Text));
}
private void GetMostRecent100HomeTimeLine()
{
var twitterContext = new TwitterContext(authorizer);
var tweets = from tweet in twitterContext.Status
where tweet.Type == StatusType.Home &&
tweet.Count == 100
select tweet;
currentTweets = tweets.ToList();
}
[An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll] are occur inside the code below
currentTweets = tweets.ToList();
My guess is it's the LinqToTwitter library trying to enumerate the 'tweets' collection and finding there's either no data, or the data cannot be retrieved. I am beginner to this topic and this is my project.
Hope someone can guide me to solve the problem