Introduction
The code shown here allows a user to get all public tweets of her /his liking without logging into Twitter and search for tweets with keywords.
It also allows the user to search for his/her friends who are tagged in his/her albums.
Using the code
The code uses Twitter API and Facebook API.
Whenever a user enters the name then it is added to Screen_Name. E.g.: If I enter Ravi then the link will look
at getting all public tweets made by the user (we can get only the top 200 tweets (public)).
We are using the asynch features of .NET 4.5 so the application will not hang during the download and the user can download pictures from
Facebook
and search for friends who are tagged in Facebook and can also share their pics which are locally stored.
After successful download of the tweets the user can download and search the tweets with any keyword.
private async void gettweets_Tapped(object sender, TappedRoutedEventArgs e) {
Windows.Web.Syndication.SyndicationClient client = new Windows.Web.Syndication.SyndicationClient();
client.BypassCacheOnRetrieve = true;
Uri feedUri = new Uri("http://api.twitter.com/1/statuses/user_timeline." +
"JSON?count=200&screen_name=XXXXXXX",UriKind.RelativeOrAbsolute);
try {
Windows.Web.Syndication.SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri);
Tweets.Text = feed.Title.Text + Environment.NewLine;
foreach (SyndicationItem item in feed.Items)
{
Tweets.Text += item.Title.Text + ", " +
item.PublishedDate.ToString() + Environment.NewLine;
}
}
catch (Exception ex) {
Tweets.Text = "I'm sorry, but I couldn't load the page," +
" possibly due to network problems." +
"Here's the error message I received: " + ex.ToString();
}
The following code will search for a keyword within the public tweets:
var subset = from g in textbx1.Text where g.Contains(searchTb.Text) select g;
foreach (var stat in subset)
{
richTextBox1.Text += stat + "\n" +
"_________________________________________________________" + "\n";
}
Similarly we use the Facebook API and download pictures from albums and share them
if they are locally available.
Users can see all public tweets without logging into Twitter and can search for friends who are tagged in their albums.
Points of interest
Here we are using the Tap event in order to make the application completely use the touch
features of the Intel Ultrabook.
We used the Twitter API and FaceBook API along with C# 4.5 and XAML. We can also download the
tweets in XML format.