Skip to content

Instantly share code, notes, and snippets.

@renestein
Created June 23, 2012 18:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renestein/2979279 to your computer and use it in GitHub Desktop.
Save renestein/2979279 to your computer and use it in GitHub Desktop.
Simple twitter account checker
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Reactive.Linq;
using System.Text;
using System.Xml.Linq;
namespace TwitterSearcher
{
class Program
{
public const int DEFAULT_MINUTES = 1;
public const string URL = "http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=vodafone_cz";
public static readonly XNamespace TWIITER_XML_NAMESPACE = "http://api.twitter.com";
static void Main(string[] args)
{
var wc = new WebClient();
var timer = Observable.Timer(TimeSpan.FromMinutes(DEFAULT_MINUTES), TimeSpan.FromMinutes(DEFAULT_MINUTES))
.Do(_ => wc.DownloadStringAsync(new Uri(URL)));
var data = Observable.FromEventPattern(
handler => wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(handler),
handler => wc.DownloadStringCompleted -= new DownloadStringCompletedEventHandler(handler))
.Retry()
.Select(ep => ((DownloadStringCompletedEventArgs) ep.EventArgs).Result)
.Select(twitterXml => (string) XElement.Parse(twitterXml).Descendants("item").First().Element("description"))
.DistinctUntilChanged(s => s, StringComparer.InvariantCultureIgnoreCase)
.Finally(wc.Dispose);
var timerSubscription = timer.Subscribe(Console.WriteLine);
var dataSubscription = data.Subscribe(Console.WriteLine);
Console.ReadLine();
timerSubscription.Dispose();
dataSubscription.Dispose();
}
}
}
@ABDULACOD3R
Copy link

helli

@ABDULACOD3R
Copy link

@

@ZonaAirdrop
Copy link

Good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment