protected virtual void DoPost(HttpListenerRequest request, NameValueCollection headers) { string contentType = request.ContentType; string sig = request.Headers["X-Hub-Signature"]; string hubSignature = null; if (!string.IsNullOrEmpty(sig) && sig.Length > 4) { hubSignature = sig.Substring(4); } SyndicationFeed feed = null; try { using (var reader = new XmlTextReader(request.InputStream)) { feed = SyndicationFeed.Load(reader); } } catch { // There was something wrong with the feed. // Just ignore it and return. return; } var args = new PushPostEventArgs(contentType, hubSignature, feed); OnPost(args); }
protected virtual void OnPost(PushPostEventArgs args) { if (PushPost != null) { PushPost(this, args); } }
static void callback_PushPost(object sender, PushPostEventArgs args) { Console.WriteLine("{0} - Received update from hub!", DateTime.Now); try { Console.WriteLine("Events:"); foreach (var update in args.Feed.Items) { //get the content from GES string evnt = GetContent(update); Console.WriteLine(evnt); } // Save the update to file. // string timestamp = DateTime.Now.ToString("yyyyMMdd_hhmm"); // string saveFilename = FeedBaseName + "_" + timestamp + FeedExtension; // Console.WriteLine("Writing feed to {0}", saveFilename); // using (var writer = XmlWriter.Create(saveFilename)) // { // args.Feed.SaveAsAtom10(writer); // } } catch (Exception ex) { Console.WriteLine("Exception!\r\n{0}", ex); } Console.WriteLine("Done"); }