<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Lazy Sys Admin &#187; Programming</title>
	<atom:link href="http://www.thelazysysadmin.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thelazysysadmin.net</link>
	<description>Why do things the hard way?</description>
	<lastBuildDate>Tue, 11 Oct 2011 05:31:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Trend API coming soon</title>
		<link>http://www.thelazysysadmin.net/2009/11/trend-api-coming-soon/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=trend-api-coming-soon</link>
		<comments>http://www.thelazysysadmin.net/2009/11/trend-api-coming-soon/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 23:08:16 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Application]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google App Engine]]></category>
		<category><![CDATA[Mashup]]></category>
		<category><![CDATA[TrendEngine]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=726</guid>
		<description><![CDATA[TrendEngine was developed using Google Hot Trends information and provided some level of stability to the constantly changing trend list. <a href="http://www.thelazysysadmin.net/2009/11/trend-api-coming-soon/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while back I started getting interested in site&#8217;s that used API&#8217;s from several different sources to create what is known as a web mashup. <em>&#8220;A mashup is a web page or application that combines data or functionality from two or more external sources to create a new service&#8221;</em> &#8211; <a href="http://en.wikipedia.org/wiki/Mashup_%28web_application_hybrid%29" target="_blank">Wikipedia</a>. There are plenty of really good examples of web mashups out there, if you are interested check out <a href="http://www.programmableweb.com/" target="_blank">ProgrammableWeb&#8217;s</a> site.</p>
<p>At this time I wrote my own craptacular mashup called <a href="http://www.thegobshite.net/" target="_blank">The Gob Shite</a>, this site was a mashup of Google&#8217;s YouTube, Google&#8217;s News feeds and a new API of my own called the TrendEngine. TrendEngine was developed using Google Hot Trends information and provided some level of stability to the constantly changing trend list. It does this by detecting reoccuring trends in the list and applying a weighting formula to them.</p>
<p><span id="more-726"></span>TrendEngine currently operates from a private server written in PHP, I am currently converting this code to Java to run on Google&#8217;s App Engine. The new TrendEngine service will be publicly released shortly and will be listed up on ProgrammableWeb for all to use.</p>
<p>More information to come soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/11/trend-api-coming-soon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>APNS error &#8211; No Valid aps-environment entitlement</title>
		<link>http://www.thelazysysadmin.net/2009/07/apns-error-no-valid-aps-environment-entitlement/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apns-error-no-valid-aps-environment-entitlement</link>
		<comments>http://www.thelazysysadmin.net/2009/07/apns-error-no-valid-aps-environment-entitlement/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 11:33:29 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[APNS]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=555</guid>
		<description><![CDATA[If you get the following error when trying to register for a device token, firstly ensure you have correctly followed the directions within the iPhone Developers Portal. If after you have verified your Provisioning Profile and application settings you still &#8230; <a href="http://www.thelazysysadmin.net/2009/07/apns-error-no-valid-aps-environment-entitlement/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you get the following error when trying to register for a device token, firstly ensure you have correctly followed the directions within the iPhone Developers Portal.</p>
<pre class="brush: plain; title: ; notranslate">
Error Domain=NSCocoaErrorDomain &quot;no valid 'aps-environment' entitlement string found for application&quot;
</pre>
<p><span id="more-555"></span>If after you have verified your Provisioning Profile and application settings you still get the error, try the following:</p>
<p>Go to the Project Settings in the Project Menu</p>
<p><a href="http://www.thelazysysadmin.net/wp-content/uploads/2009/07/APNS-Error-1.png"><img class="alignnone size-full wp-image-559" title="APNS Error 1" src="http://www.thelazysysadmin.net/wp-content/uploads/2009/07/APNS-Error-1.png" alt="APNS Error 1" width="600" height="400" /></a></p>
<p>Select the exact Code Signing identity for your application rather then the automatic selection.</p>
<p><a href="http://www.thelazysysadmin.net/wp-content/uploads/2009/07/APNS-Error-2.png"><img class="alignnone size-full wp-image-560" title="APNS Error 2" src="http://www.thelazysysadmin.net/wp-content/uploads/2009/07/APNS-Error-2.png" alt="APNS Error 2" width="600" height="536" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/07/apns-error-no-valid-aps-environment-entitlement/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>APNS Send Device Token to Provider</title>
		<link>http://www.thelazysysadmin.net/2009/07/apns-send-device-token-to-provider/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apns-send-device-token-to-provider</link>
		<comments>http://www.thelazysysadmin.net/2009/07/apns-send-device-token-to-provider/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 05:38:37 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[APNS]]></category>
		<category><![CDATA[Obj-C]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=493</guid>
		<description><![CDATA[I am currently in the middle of designing and developing an application based on the Apple Push Notification Service. There is alot of information about the client side registration and plenty of server side code examples, but I haven&#8217;t found &#8230; <a href="http://www.thelazysysadmin.net/2009/07/apns-send-device-token-to-provider/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am currently in the middle of designing and developing an application based on the Apple Push Notification Service. There is alot of information about the client side registration and plenty of server side code examples, but I haven&#8217;t found anything that simple demonstrates how to send your device token to the provider service.</p>
<p><span id="more-493"></span>The following code is simple (but as a newcomer to Obj-C took me ages to put together). Just press the View Source button on the following panel to see all the code (I am having trouble getting code wrapping to work, so this will be the case until I find a decent syntax highlighter plugin).</p>
<pre class="brush: cpp; title: ; notranslate">
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

	NSLog(@&quot;devToken=%@&quot;,deviceToken);

	NSString *host = @&quot;yourhost&quot;;
	NSString *URLString = @&quot;/register.php?id=&quot;;
	URLString = [URLString stringByAppendingString:id];
	URLString = [URLString stringByAppendingString:@&quot;&amp;amp;amp;amp;amp;amp;devicetoken=&quot;];

	NSString *dt = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@&quot;&amp;lt;&amp;gt;&quot;]];
	dt = [dt stringByReplacingOccurrencesOfString:@&quot; &quot; withString:@&quot;&quot;];

	URLString = [URLString stringByAppendingString:dt];
	URLString = [URLString stringByAppendingString:@&quot;&amp;amp;amp;amp;amp;amp;devicename=&quot;];
	URLString = [URLString stringByAppendingString:[[UIDevice alloc] name]];

	NSURL *url = [[NSURL alloc] initWithScheme:@&quot;http&quot; host:host path:URLString];
	NSLog(@&quot;FullURL=%@&quot;, url);

	NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];

	NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
}
</pre>
<p>If you spot the above code and think &#8220;why the hell has he done it like that&#8221;, it is because I don&#8217;t know any better at the moment. If there is a better way please leave some constructive feedback via the comment form.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/07/apns-send-device-token-to-provider/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>iPhone Development</title>
		<link>http://www.thelazysysadmin.net/2009/07/iphone-development/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=iphone-development</link>
		<comments>http://www.thelazysysadmin.net/2009/07/iphone-development/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 03:32:40 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Alerts]]></category>
		<category><![CDATA[APNS]]></category>
		<category><![CDATA[Pager]]></category>
		<category><![CDATA[Push]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=482</guid>
		<description><![CDATA[For some strange, but unknown reason I decided to purchase a Mac Mini to try some iPhone Development. I have a few apps that I would like on my iPhone that are currently not available. <a href="http://www.thelazysysadmin.net/2009/07/iphone-development/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For some strange, but unknown reason I decided to purchase a Mac Mini to try some iPhone Development. I have a few apps that I would like on my iPhone that are currently not available.</p>
<p>My first app will be for a Nagios Pager service that will utilise the Push Notification features just released in iPhone OS 3.0. There will be two versions, Nagios Pager and Nagios Pager Pro. Nagios Pager will be a stand alone application that will talk to a backend service for delivering Push Notifications for Nagios alerts, Nagios Pager Pro will contain all the features of Nagios Pager as well as an iPhone based Nagios client.</p>
<p><span id="more-482"></span>The standard version will be released in the App Store for free and the Pro version will be for a small cost. There will also be various access methods for the backend service required for the Apple Push Notification Service (APNS). A free subscription to the backend will allow for one phone to access one nagios backend, while a paid subscription will allow for multiple phones access to multiple backends.</p>
<p>If you are interested in this service or you are interested in entering the beta program let me know via a comment and I will get in contact with you. Stay tuned for more development news.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/07/iphone-development/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Simple .NET XML Tutorial</title>
		<link>http://www.thelazysysadmin.net/2009/05/simple-dotnet-xml-tutorial/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-dotnet-xml-tutorial</link>
		<comments>http://www.thelazysysadmin.net/2009/05/simple-dotnet-xml-tutorial/#comments</comments>
		<pubDate>Thu, 07 May 2009 02:51:08 +0000</pubDate>
		<dc:creator>Jon Smith</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.thelazysysadmin.net/?p=114</guid>
		<description><![CDATA[I needed to build an application the other day that used XML to talk to a web service, but I wanted to deal with raw XML rather then using anything based on WSDL and RPC. This was the first time &#8230; <a href="http://www.thelazysysadmin.net/2009/05/simple-dotnet-xml-tutorial/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I needed to build an application the other day that used XML to talk to a web service, but I wanted to deal with raw XML rather then using anything based on WSDL and RPC. This was the first time I had written anything that used XML before so I started googling for code examples and tutorials.</p>
<p>There wasn&#8217;t much clear documentation out there on exactly what I wanted to do so I ended up using a couple of code examples I found in the end (links provided below for original source) and modifying them for my needs.</p>
<p>The end result is extremely simple to understand (however the information was not easy to find) so I thought I would post the details here in hopes that someone else wanting to do the same thing ends up finding this article rather than searching for hours and not finding exactly what is required. (As an a-side, most of what I found online was regarding using premade XML files, and the generation of XML files and not generating and sending the XML request on the fly). Also I wasted a bit of time because of my lack of knowledge on how various Streams work together, but that is another issue entirely.</p>
<p>The following is code for C# but should apply to other .NET based languages (with an appropriate change of syntax).</p>
<p>Required Namespace Imports</p>
<pre class="brush: csharp; title: ; notranslate">
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.IO;
using System.Net;
using System.Threading;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
</pre>
<p>Code</p>
<pre class="brush: csharp; title: ; notranslate">
WebRequest req = WebRequest.Create(&quot;http://URLHERE/WebService&quot;);
req.Method = &quot;POST&quot;;
req.ContentType = &quot;text/xml&quot;;
Stream requestStream = req.GetRequestStream();

XmlTextWriter xml = new XmlTextWriter(requestStream, null);

xml.WriteStartDocument();

// The DocType will be different for most situations, this
// is what works for me.
xml.WriteDocType(&quot;Request&quot;, null, &quot;somefile.dtd&quot;, null);
xml.WriteStartElement(&quot;Request&quot;);
xml.WriteStartElement(&quot;InfoRequest&quot;);

// These values could come from any source
xml.WriteElementString(&quot;Username&quot;, &quot;&lt;&gt;&quot;);
xml.WriteElementString(&quot;Password&quot;, &quot;&lt;
&gt;&quot;);
xml.WriteElementString(&quot;Info&quot;, &quot;something&quot;);
xml.WriteEndElement();
xml.WriteEndElement();

// When Close() is called the request is sent to the server
xml.Close();

// Use a WebResponse Component to retrieve the response
WebResponse rsp = req.GetResponse();
XmlTextReader xmlin = new XmlTextReader(rsp.GetResponseStream());

while (xmlin.Read())
{
  if (xmlin.NodeType == XmlNodeType.Element)
  {
    if (xmlin.Name == &quot;Info&quot;)
    {
      String info = xmlin.ReadString();

      // Do something with returned data

    }
  }
}

xmlin.Close();
rsp.Close();
</pre>
<p>There are plenty of useful tutorials out there based on XmlTextReader and XmlTextWriter that can explain how to use them to read and write XML. So I wont cover that here. My biggest problem was finding out how to generate the XML and send it straight to the server without having to save to a file.</p>
<p>References:</p>
<ul>
<li><a href="http://www.aspsms.com/examples/c/">http://www.aspsms.com/examples/c/</a></li>
<li><a href="http://www.codeproject.com/KB/dotnet/XmlPost.aspx">http://www.codeproject.com/KB/dotnet/XmlPost.aspx</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.thelazysysadmin.net/2009/05/simple-dotnet-xml-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

