<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Moryadesign&#039;s Blog</title>
	<atom:link href="http://moryadesigns.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://moryadesigns.wordpress.com</link>
	<description>Elegant in design</description>
	<lastBuildDate>Thu, 21 Jul 2011 12:39:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='moryadesigns.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/d44348b9830dcda280bc815183c8f6c5?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Moryadesign&#039;s Blog</title>
		<link>http://moryadesigns.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://moryadesigns.wordpress.com/osd.xml" title="Moryadesign&#039;s Blog" />
	<atom:link rel='hub' href='http://moryadesigns.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Session in PHP &#8211; Chapter 5</title>
		<link>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-5/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-5/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 04:00:41 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[moryadesigns]]></category>
		<category><![CDATA[null script]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php code]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/?p=181</guid>
		<description><![CDATA[Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=181&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span style="text-align:center; display: block;"><a href="http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-5/"><img src="http://img.youtube.com/vi/E_xdSizFr3s/2.jpg" alt="" /></a></span>
<br />Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/181/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/181/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/181/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=181&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>
	</item>
		<item>
		<title>Session in PHP &#8211; Chapter 4</title>
		<link>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-4/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-4/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 03:54:25 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[moryadesigns]]></category>
		<category><![CDATA[null script]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php code]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/?p=179</guid>
		<description><![CDATA[Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=179&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span style="text-align:center; display: block;"><a href="http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-4/"><img src="http://img.youtube.com/vi/lxgYCTASgQ0/2.jpg" alt="" /></a></span>
<br />Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/179/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=179&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>
	</item>
		<item>
		<title>Session in PHP &#8211; Chapter 3</title>
		<link>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-3/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-3/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 03:53:01 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[moryadesigns]]></category>
		<category><![CDATA[null script]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php code]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/?p=176</guid>
		<description><![CDATA[Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=176&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span style="text-align:center; display: block;"><a href="http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-3/"><img src="http://img.youtube.com/vi/sQl2iKqptC8/2.jpg" alt="" /></a></span>
<br />Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=176&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/27/session-in-php-chapter-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>
	</item>
		<item>
		<title>Sessions In PHP &#8211; Chapter 2</title>
		<link>http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-2/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-2/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 03:50:41 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[moryadesigns]]></category>
		<category><![CDATA[null script]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php code]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/?p=174</guid>
		<description><![CDATA[Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=174&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span style="text-align:center; display: block;"><a href="http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-2/"><img src="http://img.youtube.com/vi/85BxCxJ7oJ4/2.jpg" alt="" /></a></span>
<br />Posted in PHP Scripts Tagged: moryadesigns, null script, php, php code, Session <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/174/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/174/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/174/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=174&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>
	</item>
		<item>
		<title>Sessions in PHP-Chapter 1</title>
		<link>http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-1/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-1/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 03:48:19 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[mory]]></category>
		<category><![CDATA[moryadesigns]]></category>
		<category><![CDATA[moryadesigns@gmail.com]]></category>
		<category><![CDATA[null script]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php code]]></category>
		<category><![CDATA[Session]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/?p=171</guid>
		<description><![CDATA[Posted in PHP Scripts Tagged: mory, moryadesigns, moryadesigns@gmail.com, null script, php, php code, Session<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=171&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span style="text-align:center; display: block;"><a href="http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-1/"><img src="http://img.youtube.com/vi/9tIaInzSLaw/2.jpg" alt="" /></a></span>
<br />Posted in PHP Scripts Tagged: mory, moryadesigns, moryadesigns@gmail.com, null script, php, php code, Session <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/171/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=171&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/27/sessions-in-php-chapter-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>
	</item>
		<item>
		<title>Integrate your PHP application with Google Contacts</title>
		<link>http://moryadesigns.wordpress.com/2009/09/24/integrate-your-php-application-with-google-contacts/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/24/integrate-your-php-application-with-google-contacts/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 06:14:00 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[PHP Scripts]]></category>
		<category><![CDATA[contact grabber]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Google Contacts]]></category>
		<category><![CDATA[null script]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php script]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/2009/09/24/integrate-your-php-application-with-google-contacts/</guid>
		<description><![CDATA[Integrate your PHP application with Google Contacts Read and write contact information from Google Contacts with XML and PHP Summary:&#160; The Google Contacts Data API provides a powerful, client-neutral API to read and modify a user&#8217;s private Gmail contact information. Learn to retrieve, add, delete, and modify contacts through a custom PHP application with this [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=170&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Integrate your PHP application with Google Contacts</h3>
<p><em>Read and write contact information from Google Contacts with XML and PHP</em></p>
<p><b>Summary:</b>&#160; The Google Contacts Data API provides a powerful, client-neutral API to read and modify a user&#8217;s private Gmail contact information. Learn to retrieve, add, delete, and modify contacts through a custom PHP application with this API in an application context.</p>
<p><a name="N100AC">Understanding the Google Contacts API</a></p>
<p>Before you dive into the PHP code, a few words about the Google Contacts Data API are in order. As with other Google Data APIs, the system accepts HTTP requests that contain one or more XML-encoded input arguments and return Atom feeds that contain the requested information. These feeds can then be parsed in any XML-aware programming language. In addition, the standard HTTP operations of GET, POST, PUT, and DELETE are mapped to API methods that retrieve, add, update, and delete records respectively.</p>
<p>A typical Google Contacts feed contains a lot of information. Consider the example in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c1">Listing 1</a>:</p>
<p><a name="c1"><b>Listing 1: An example Google Contacts feed</b></a></p>
<pre>&lt;atom:feed xmlns:atom=&quot;http://www.w3.org/2005/Atom&quot;&gt;
  &lt;atom:author&gt;
    &lt;atom:name&gt;John Doe&lt;/atom:name&gt;
    &lt;atom:email&gt;user@gmail.com&lt;/atom:email&gt;
  &lt;/atom:author&gt;
  &lt;atom:category term=&quot;http://schemas.google.com/contact/2008#contact&quot;
   scheme=&quot;http://schemas.google.com/g/2005#kind&quot;/&gt;
  &lt;atom:id&gt;user@gmail.com&lt;/atom:id&gt;
  &lt;atom:link href=&quot;http://www.google.com/&quot; rel=&quot;alternate&quot; type=&quot;text/html&quot;/&gt;
  &lt;atom:link href=&quot;http://www.google.com/m8/feeds/contacts/user%40gmail.com/full&quot;
   rel=&quot;http://schemas.google.com/g/2005#feed&quot; type=&quot;application/atom+xml&quot;/&gt;
  &lt;atom:link href=&quot;http://www.google.com/m8/feeds/contacts/user%40gmail.com/full&quot;
   rel=&quot;http://schemas.google.com/g/2005#post&quot; type=&quot;application/atom+xml&quot;/&gt;
  &lt;atom:link href=&quot;http://www.google.com/m8/feeds/contacts/user%40gmail.com/full/
   batch&quot; rel=&quot;http://schemas.google.com/g/2005#batch&quot; type=&quot;application/atom+xml&quot;/&gt;
  &lt;atom:link href=&quot;http://www.google.com/m8/feeds/contacts/user%40gmail.com/full?
   max-results=25&quot; rel=&quot;self&quot; type=&quot;application/atom+xml&quot;/&gt;
  &lt;atom:link href=&quot;http://www.google.com/m8/feeds/contacts/user%40gmail.com/full?
   start-index=26&amp;max-results=25&quot; rel=&quot;next&quot; type=&quot;application/atom+xml&quot;/&gt;
  &lt;atom:title type=&quot;text&quot;&gt;John Doe's Contacts&lt;/atom:title&gt;
  &lt;atom:updated&gt;2009-08-31T10:48:00.410Z&lt;/atom:updated&gt;
  &lt;atom:generator uri=&quot;http://www.google.com/m8/feeds&quot; version=&quot;1.0&quot;&gt;Contacts
  &lt;/atom:generator&gt;
  &lt;atom:entry xmlns:default=&quot;http://www.w3.org/2007/app&quot;
   xmlns:default1=&quot;http://schemas.google.com/g/2005&quot;
   xmlns:default2=&quot;http://schemas.google.com/contact/2008&quot;&gt;
    &lt;default:edited xmlns=&quot;http://www.w3.org/2007/app&quot;&gt;2009-08-22T16:52:37.457Z
    &lt;/default:edited&gt;
    &lt;default1:name xmlns=&quot;http://schemas.google.com/g/2005&quot;&gt;
      &lt;default1:fullName&gt;Vikram Vaswani&lt;/default1:fullName&gt;
      &lt;default1:givenName&gt;Vikram&lt;/default1:givenName&gt;
      &lt;default1:familyName&gt;Vaswani&lt;/default1:familyName&gt;
    &lt;/default1:name&gt;
    &lt;default1:organization xmlns=&quot;http://schemas.google.com/g/2005&quot;
     rel=&quot;http://schemas.google.com/g/2005#work&quot;&gt;
      &lt;default1:orgName&gt;Melonfire&lt;/default1:orgName&gt;
      &lt;default1:orgTitle&gt;CEO&lt;/default1:orgTitle&gt;
    &lt;/default1:organization&gt;
    &lt;default1:email xmlns=&quot;http://schemas.google.com/g/2005&quot;
     rel=&quot;http://schemas.google.com/g/2005#other&quot; address=&quot;vikram@example.org&quot;
     primary=&quot;true&quot;/&gt;
    &lt;default1:email xmlns=&quot;http://schemas.google.com/g/2005&quot;
     rel=&quot;http://schemas.google.com/g/2005#home&quot; address=&quot;vikram@example.com&quot;/&gt;
    &lt;default1:phoneNumber xmlns=&quot;http://schemas.google.com/g/2005&quot;
     rel=&quot;http://schemas.google.com/g/2005#mobile&quot;&gt;0012345678901
     &lt;/default1:phoneNumber&gt;
    &lt;default1:phoneNumber xmlns=&quot;http://schemas.google.com/g/2005&quot;
     rel=&quot;http://schemas.google.com/g/2005#work_fax&quot;&gt;0045678901234
     &lt;/default1:phoneNumber&gt;
    &lt;default2:website xmlns=&quot;http://schemas.google.com/contact/2008&quot;
     href=&quot;http://www.melonfire.com/&quot; rel=&quot;home&quot;/&gt;
    &lt;default2:website xmlns=&quot;http://schemas.google.com/contact/2008&quot;
     href=&quot;http://www.php-beginners-guide.com/&quot; rel=&quot;blog&quot;/&gt;
    &lt;default2:groupMembershipInfo xmlns=&quot;http://schemas.google.com/contact/2008&quot;
     deleted=&quot;false&quot;
     href=&quot;http://www.google.com/m8/feeds/groups/user%40gmail.com/base/6&quot;/&gt;
    &lt;atom:category term=&quot;http://schemas.google.com/contact/2008#contact&quot;
     scheme=&quot;http://schemas.google.com/g/2005#kind&quot;/&gt;
    &lt;atom:id&gt;http://www.google.com/m8/feeds/contacts/user%40gmail.com/base/0
    &lt;/atom:id&gt;
    &lt;atom:link href=&quot;http://www.google.com/m8/feeds/photos/media/user%40gmail.com/0&quot;
     rel=&quot;http://schemas.google.com/contacts/2008/rel#photo&quot; type=&quot;image/*&quot;/&gt;
    &lt;atom:link href=&quot;http://www.google.com/m8/feeds/contacts/user%40gmail.com/full/0&quot;
     rel=&quot;self&quot; type=&quot;application/atom+xml&quot;/&gt;
    &lt;atom:link href=&quot;http://www.google.com/m8/feeds/contacts/user%40gmail.com/full/0&quot;
     rel=&quot;edit&quot; type=&quot;application/atom+xml&quot;/&gt;
    &lt;atom:title type=&quot;text&quot;&gt;Vikram Vaswani&lt;/atom:title&gt;
    &lt;atom:updated&gt;2009-08-22T16:52:37.457Z&lt;/atom:updated&gt;
    &lt;atom:content type=&quot;text&quot;&gt;PHP enthusiast&lt;/atom:content&gt;
  &lt;/atom:entry&gt;
  &lt;atom:entry xmlns:default=&quot;http://www.w3.org/2007/app&quot;
   xmlns:default1=&quot;http://schemas.google.com/g/2005&quot;&gt;
  &lt;/atom:entry&gt;
  &lt;openSearch:totalResults xmlns:openSearch=&quot;http://a9.com/-/spec/opensearchrss/1.0/&quot;
  &gt;153&lt;/openSearch:totalResults&gt;
  &lt;openSearch:startIndex xmlns:openSearch=&quot;http://a9.com/-/spec/opensearchrss/1.0/&quot;
  &gt;1&lt;/openSearch:startIndex&gt;
  &lt;openSearch:itemsPerPage xmlns:openSearch=&quot;http://a9.com/-/spec/opensearchrss/1.0/&quot;
  &gt;25&lt;/openSearch:itemsPerPage&gt;
&lt;/atom:feed&gt;</pre>
<p>Every Contacts feed opens with a <code>&lt;feed&gt;</code> element as the root element. The <code>&lt;feed&gt;</code> element contains <code>&lt;link&gt;</code> elements, which contain URLs for different versions of the feed, and <code>&lt;openSearch:&gt;</code> elements, which contain summary statistics.</p>
<p>The outermost <code>&lt;feed&gt;</code> element encloses one or more <code>&lt;entry&gt;</code> elements, each representing a single contact. Each <code>&lt;entry&gt;</code> contains further detail, including the contact&#8217;s name, organization, title, e-mail addresses, phone and fax numbers, Web sites and photograph (among other things). Each <code>&lt;entry&gt;</code> also contains two further <code>&lt;link&gt;</code> elements, <code>&lt;link rel=&quot;self&quot; ...&gt;</code> and <code>&lt;link rel=&quot;edit&quot; ...&gt;</code>, which hold the URLs for retrieving the complete entry and for editing the entry, respectively.</p>
<p><a name="N100F8">Retrieving contacts</a></p>
<p>It&#8217;s important to note that Google Contacts feeds are private. This means that any operation on the data contained in the feed—including merely viewing it— will only be successful if the operation is authenticated with the username and password of the feed owner using one of the two Google-approved authentication methods: AuthSub or ClientLogin.</p>
<p>To perform this type of authentication manually is a fairly messy task, and requires a fair bit of code to account for the various scenarios that might crop up during a typical authentication transaction. Fortunately, you don&#8217;t have to worry too much about this: Zend&#8217;s® GData Client Library, designed specifically for developers who integrate PHP applications with the Google Data API, handles all the details for you. This library, which you can download separately (see <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#resources">Resources</a> for a link), provides a convenient, object-oriented interface to the Google Data API, encapsulate a most common tasks (including authentication), and leaves you free to focus on the core functions of your application. The remaining examples in this article will make use of this library, so ensure you have it installed before proceeding.</p>
<p>Once you install Zend&#8217;s GData library, let&#8217;s proceed to an example of processing a Google Contacts Data API feed using PHP. <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c2">Listing 2</a> takes the feed from <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c1">Listing 1</a> and uses SimpleXML to extract relevant fragments of data from it and format it into a Web page:</p>
<p><a name="c2"><b>Listing 2: Retrieving and displaying contacts</b></a></p>
<pre>&lt;!DOCTYPE html
  PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;Listing contacts&lt;/title&gt;
    &lt;style&gt;
    body {
      font-family: Verdana;
    }
    div.name {
      color: red;
      text-decoration: none;
      font-weight: bolder;
    }
    div.entry {
      display: inline;
      float: left;
      width: 400px;
      height: 150px;
      border: 2px solid;
      margin: 10px;
      padding: 5px;
    }
    td {
      vertical-align: top;
    }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;

    &lt;?php
    // load Zend Gdata libraries
    require_once 'Zend/Loader.php';
    Zend_Loader::loadClass('Zend_Gdata');
    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    Zend_Loader::loadClass('Zend_Http_Client');
    Zend_Loader::loadClass('Zend_Gdata_Query');
    Zend_Loader::loadClass('Zend_Gdata_Feed');

    // set credentials for ClientLogin authentication
    $user = &quot;user@gmail.com&quot;;
    $pass = &quot;guessme&quot;;

    try {
      // perform login and set protocol version to 3.0
      $client = Zend_Gdata_ClientLogin::getHttpClient(
        $user, $pass, 'cp');
      $gdata = new Zend_Gdata($client);
      $gdata-&gt;setMajorProtocolVersion(3);

      // perform query and get result feed
      $query = new Zend_Gdata_Query(
        'http://www.google.com/m8/feeds/contacts/default/full');
      $feed = $gdata-&gt;getFeed($query);

      // display title and result count
      ?&gt;

      &lt;h2&gt;&lt;?php echo $feed-&gt;title; ?&gt;&lt;/h2&gt;
      &lt;div&gt;
      &lt;?php echo $feed-&gt;totalResults; ?&gt; contact(s) found.
      &lt;/div&gt;

      &lt;?php
      // parse feed and extract contact information
      // into simpler objects
      $results = array();
      foreach($feed as $entry){
        $xml = simplexml_load_string($entry-&gt;getXML());
        $obj = new stdClass;
        $obj-&gt;name = (string) $entry-&gt;title;
        $obj-&gt;orgName = (string) $xml-&gt;organization-&gt;orgName;
        $obj-&gt;orgTitle = (string) $xml-&gt;organization-&gt;orgTitle; 

        foreach ($xml-&gt;email as $e) {
          $obj-&gt;emailAddress[] = (string) $e['address'];
        }

        foreach ($xml-&gt;phoneNumber as $p) {
          $obj-&gt;phoneNumber[] = (string) $p;
        }
        foreach ($xml-&gt;website as $w) {
          $obj-&gt;website[] = (string) $w['href'];
        }

        $results[] = $obj;
      }
    } catch (Exception $e) {
      die('ERROR:' . $e-&gt;getMessage());
    }
    ?&gt;

    &lt;?php
    // display results
    foreach ($results as $r) {
    ?&gt;
    &lt;div class=&quot;entry&quot;&gt;
      &lt;div class=&quot;name&quot;&gt;&lt;?php echo (!empty($r-&gt;name)) ?
       $r-&gt;name : 'Name not available'; ?&gt;&lt;/div&gt;
      &lt;div class=&quot;data&quot;&gt;
        &lt;table&gt;
          &lt;tr&gt;
            &lt;td&gt;Organization&lt;/td&gt;
            &lt;td&gt;&lt;?php echo $r-&gt;orgName; ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Email&lt;/td&gt;
            &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;emailAddress); ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Phone&lt;/td&gt;
            &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;phoneNumber); ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Web&lt;/td&gt;
            &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;website); ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;?php
    }
    ?&gt;

  &lt;/body&gt;
&lt;/html&gt;</pre>
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f1">Figure 1</a> demonstrates the output you might see. In the screen capture, some personal e-mail address information is masked.</p>
<p><a name="f1"><b>Figure 1. A Web page that lists contacts</b></a></p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/image1.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image1" border="0" alt="image1" src="http://moryadesigns.files.wordpress.com/2009/09/image1_thumb.jpg?w=395&#038;h=283" width="395" height="283" /></a> </p>
<p>First <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c2">Listing 2</a> loads the Zend class libraries, and then initializes an instance of the Zend_Gdata service class. This class makes use of a Zend_Http_Client object, which is provided with the necessary user authentication information and used to open an authenticated connection to the Google Contacts service. Once an authenticated connection is open, the <code>getFeed()</code> method retrieves the contacts feed. This method accepts a Zend_Gdata_Query object, which is passed the feed URL. Note also the call to the <code>setMajorProtocolVersion()</code> in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c2">Listing 2</a>, which tells the server to use v3.0 of the Google Contacts Data API; this is a required call. If you omit it, you might see unexpected behaviour.</p>
<p>The response to the <code>getFeed()</code> API call is an XML feed similar to that in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c1">Listing 1</a>, which is then parsed and converted into a PHP object. Entries within the feed are represented as array elements, making it possible to iterate over the feed and retrieve the individual contact entries. Since SimpleXML provides an easier way to retrieve specific pieces of information from an XML tree, the <code>simplexml_load_string()</code> method is used to convert the XML of each entry into a SimpleXML object. Child nodes under each <code>&lt;entry&gt;</code> are then retrieved and flattened into a simpler object for easy retrieval, and each resulting object is then placed in the <code>$results</code> array. Once the entire feed is processed, you can easily iterate over the <code>$results</code> array with a <code>foreach()</code> loop and format the contents for display in a Web browser. </p>
<p>A few words here about the feed URL passed to the Zend_Gdata_Query object: it&#8217;s generated by appending the user name and feed type to the standard feed URL, in the http://www.google.com/m8/feeds/contacts/USERID/TYPE. Feed types come in two varieties, full and thin, with the latter returning only a subset of the entire entry. And using the special keyword <code>default</code> in place of the user name, as in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c2">Listing 2</a>, returns the user&#8217;s default feed. </p>
<p>&#160;</p>
<p><a name="N10175">Adding contacts</a></p>
<p>So that takes care of listing contacts. Now, how about adding new contacts?</p>
<p>This is actually not as complicated as it might seem. To add a new contact, simply POST a new XML-encoded <code>&lt;entry&gt;</code> block to the feed URL. <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c3">Listing 3</a> has an example of one such block:</p>
<p><a name="c3"><b>Listing 3: An example Google Contacts entry</b></a></p>
<pre>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;atom:entry xmlns:atom=&quot;http://www.w3.org/2005/Atom&quot;
 xmlns:gd=&quot;http://schemas.google.com/g/2005&quot;&gt;
  &lt;gd:name&gt;
    &lt;gd:fullName&gt;Jack Frost&lt;/gd:fullName&gt;
  &lt;/gd:name&gt;
  &lt;gd:email address=&quot;jack.frost@example.com&quot;
   rel=&quot;http://schemas.google.com/g/2005#home&quot;/&gt;
  &lt;gd:organization rel=&quot;http://schemas.google.com/g/2005#work&quot;&gt;
    &lt;gd:orgName&gt;Winter Inc.&lt;/gd:orgName&gt;
  &lt;/gd:organization&gt;
&lt;/atom:entry&gt;</pre>
<p>If you use the Zend library, things are even simpler: all you need to do is call the <code>insertEntry()</code> method, which creates a POST request and transmitting the data to the feed URL. <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c4">Listing 4</a> has an example:</p>
<p><a name="c4"><b>Listing 4: Adding a new contact</b></a></p>
<pre>&lt;?php
// load Zend Gdata libraries
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');

// set credentials for ClientLogin authentication
$user = &quot;user@gmail.com&quot;;
$pass = &quot;guessme&quot;;

try {
  // perform login and set protocol version to 3.0
  $client = Zend_Gdata_ClientLogin::getHttpClient(
    $user, $pass, 'cp');
  $gdata = new Zend_Gdata($client);
  $gdata-&gt;setMajorProtocolVersion(3);

  // create new entry
  $doc  = new DOMDocument();
  $doc-&gt;formatOutput = true;
  $entry = $doc-&gt;createElement('atom:entry');
  $entry-&gt;setAttributeNS('http://www.w3.org/2000/xmlns/' ,
   'xmlns:atom', 'http://www.w3.org/2005/Atom');
  $entry-&gt;setAttributeNS('http://www.w3.org/2000/xmlns/' ,
   'xmlns:gd', 'http://schemas.google.com/g/2005');
  $doc-&gt;appendChild($entry);

  // add name element
  $name = $doc-&gt;createElement('gd:name');
  $entry-&gt;appendChild($name);
  $fullName = $doc-&gt;createElement('gd:fullName', 'Jack Frost');
  $name-&gt;appendChild($fullName);

  // add email element
  $email = $doc-&gt;createElement('gd:email');
  $email-&gt;setAttribute('address' ,'jack.frost@example.com');
  $email-&gt;setAttribute('rel' ,'http://schemas.google.com/g/2005#home');
  $entry-&gt;appendChild($email);

  // add org name element
  $org = $doc-&gt;createElement('gd:organization');
  $org-&gt;setAttribute('rel' ,'http://schemas.google.com/g/2005#work');
  $entry-&gt;appendChild($org);
  $orgName = $doc-&gt;createElement('gd:orgName', 'Winter Inc.');
  $org-&gt;appendChild($orgName);

  // insert entry
  $entryResult = $gdata-&gt;insertEntry($doc-&gt;saveXML(),
   'http://www.google.com/m8/feeds/contacts/default/full');
  echo '&lt;h2&gt;Add Contact&lt;/h2&gt;';
  echo 'The ID of the new entry is: ' . $entryResult-&gt;id;
} catch (Exception $e) {
  die('ERROR:' . $e-&gt;getMessage());
}
?&gt;</pre>
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c4">Listing 4</a> opens an authenticated connection to the Google Contacts Data API using the Zend_Gdata object, as seen earlier in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c2">Listing 2</a>. Next, the DOM extension in PHP dynamically constructs the XML <code>&lt;entry&gt;</code> shown in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c3">Listing 3</a>, and the <code>insertEntry()</code> method is used to actually save the resulting XML to the Google servers. Once the entry is added, it should immediately become visible in the Google Contacts interface.</p>
<p>Note that you can explicitly mark e-mail addresses and phone numbers as belonging to &quot;home&quot;, &quot;work&quot; or &quot;mobile&quot; by specifying the appropriate schema in the <code>&lt;gd:organization rel=&quot;...&quot; /&gt;</code> element.</p>
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f2">Figure 2</a> illustrates the output after successfully adding a new contact entry:</p>
<p>&#160;</p>
<p><a name="f2"><b>Figure 2. The output after you add a new contact</b></a></p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/image2.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image2" border="0" alt="image2" src="http://moryadesigns.files.wordpress.com/2009/09/image2_thumb.jpg?w=389&#038;h=278" width="389" height="278" /></a> </p>
<p>In the screen capture in Figure 2, some fields are masked in the confirmation message from Google. The message is in the format: <code>The ID of the new entry is http://www.google.com/m8/feeds/contacts/USER_ID/base/CONTACT_ID.</code></p>
<p>And <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f3">Figure 3</a> shows how it looks in the Google Contacts interface:</p>
<p><a name="f3"><b>Figure 3. The newly-added contact in Gmail</b></a></p>
<p>&#160;</p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/image3.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image3" border="0" alt="image3" src="http://moryadesigns.files.wordpress.com/2009/09/image3_thumb.jpg?w=400&#038;h=286" width="400" height="286" /></a> </p>
<p><a name="N101F6">Deleting and updating contacts</a></p>
<p>The Google Contacts Data API also permits you to edit and delete entries. To delete an entry, send a DELETE request to the edit URL of the contact, which is the URL specified in the entry&#8217;s <code>&lt;link rel=&quot;edit&quot; ...&gt;</code> element. In the Zend library context, you can simply pass this URL to the <code>delete()</code> method of the Zend_Gdata object, as illustrated in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c5">Listing 5</a>:</p>
<p><a name="c5"><b>Listing 5: Deleting a contact</b></a></p>
<pre>&lt;?php
// load Zend Gdata libraries
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');

// set credentials for ClientLogin authentication
$user = &quot;user@gmail.com&quot;;
$pass = &quot;guessme&quot;;

// set ID of entry to delete
// from &lt;link rel=edit&gt;
$id = 'http://www.google.com/m8/feeds/contacts/default/base/29e98jf648c495c7b';

try {
  // perform login and set protocol version to 3.0
  $client = Zend_Gdata_ClientLogin::getHttpClient(
    $user, $pass, 'cp');
  $client-&gt;setHeaders('If-Match: *');
  $gdata = new Zend_Gdata($client);
  $gdata-&gt;setMajorProtocolVersion(3);

  // delete entry
  $gdata-&gt;delete($id);
  echo '&lt;h2&gt;Delete Contact&lt;/h2&gt;';
  echo 'Entry deleted';
} catch (Exception $e) {
  die('ERROR:' . $e-&gt;getMessage());
}
?&gt;</pre>
<p>To edit an entry, use the <code>getEntry()</code> method to retrieve the entry using its unique identifier, change the values you wish to update. Then save the entry back to the server with the <code>updateEntry()</code> method of the Zend_Gdata object, which sends a PUT request to the URL specified in the <code>&lt;link rel=&quot;self&quot; ...&gt;</code> element of the entry. <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c6">Listing 6</a> illustrates the process, setting a new name and e-mail address for a contact entry:</p>
<p><a name="c6"><b>Listing 6: Modifying a contact</b></a></p>
<pre>&lt;?php
// load Zend Gdata libraries
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');

// set credentials for ClientLogin authentication
$user = &quot;user@gmail.com&quot;;
$pass = &quot;guessme&quot;;

// set ID of entry to update
// from &lt;link rel=self&gt;
$id = 'http://www.google.com/m8/feeds/contacts/default/full/0';

try {
  // perform login and set protocol version to 3.0
  $client = Zend_Gdata_ClientLogin::getHttpClient(
    $user, $pass, 'cp');
  $client-&gt;setHeaders('If-Match: *');

  $gdata = new Zend_Gdata($client);
  $gdata-&gt;setMajorProtocolVersion(3);

  // perform query and get entry
  $query = new Zend_Gdata_Query($id);
  $entry = $gdata-&gt;getEntry($query);
  $xml = simplexml_load_string($entry-&gt;getXML());

  // change name
  $xml-&gt;name-&gt;fullName = 'John Rabbit';

  // change primary email address
  foreach ($xml-&gt;email as $email) {
    if (isset($email['primary'])) {
      $email['address'] = 'jr@example.com';
    }
  }

  // update entry
  $entryResult = $gdata-&gt;updateEntry($xml-&gt;saveXML(),
   $entry-&gt;getEditLink()-&gt;href);
  echo 'Entry updated';
} catch (Exception $e) {
  die('ERROR:' . $e-&gt;getMessage());
}
?&gt;</pre>
<p>Notice that <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c5">Listing 5</a> and <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c6">Listing 6</a> both add an additional &quot;If-Match&quot; header as part of the HTTP request. This header is of particular benefit in a multi-client environment, as it can be used to delete or update an entry only if it hasn&#8217;t already been changed since it was last read. The Google Contacts Data API Developers Guide (see <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#resources">Resources</a> for a link) discusses this header in more detail.</p>
<hr />
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#ibm-pcon"></a></p>
<p><a name="N10241">Using additional parameters</a></p>
<p>The Google Contacts Data API also supports a number of additional parameters that you can use to control the result feed. Here&#8217;s a list:</p>
<ul>
<li>The <code>start-index</code> parameter specifies the start offset for the feed </li>
<li>The <code>max-results</code> parameter specifies the number of entries in the feed </li>
<li>The <code>orderby</code> and <code>sortorder</code> parameters specify how to sort feed entries </li>
<li>The <code>showdeleted</code> parameter includes entries deleted in the last 30 days in the feed </li>
</ul>
<p>If you use the Zend client library, you can set many of these parameters simply by setting the corresponding property of the Zend_Gdata_Query object. For those parameters that are specific to the service, the Zend_Gdata_Query object also offers a <code>setParam()</code> method. Both these techniques are illustrated in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c7">Listing 7</a>, which restricts the result set to 10 entries, sorted in descending order by their last modified date.</p>
<p><a name="c7"><b>Listing 7: Setting additional query parameters</b></a></p>
<pre>&lt;?php
// load Zend Gdata libraries
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');

// set credentials for ClientLogin authentication
$user = &quot;user@gmail.com&quot;;
$pass = &quot;guessme&quot;;

try {
  // perform login and set protocol version to 3.0
  $client = Zend_Gdata_ClientLogin::getHttpClient(
    $user, $pass, 'cp');
  $gdata = new Zend_Gdata($client);
  $gdata-&gt;setMajorProtocolVersion(3);

  // perform query and get result feed
  $query = new Zend_Gdata_Query(
    'http://www.google.com/m8/feeds/contacts/default/full');
  $query-&gt;maxResults = 10;
  $query-&gt;setParam('orderby', 'lastmodified');
  $query-&gt;setParam('sortorder', 'descending');
  $feed = $gdata-&gt;getFeed($query);

  // display title and result count
  // snip...
} catch (Exception $e) {
  die('ERROR:' . $e-&gt;getMessage());
}
?&gt;</pre>
<hr />
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#ibm-pcon"></a></p>
<p><a name="N10282">A simple application</a></p>
<p>Now that you know how the Google Contacts Data API works, you can try to build a simple PHP application that allows contact entry and manipulation. This prototype application has 3 scripts (see <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#download">Download</a> for a zipped file):</p>
<ul>
<li>contacts-index.php lists contact entries and provides links to add and delete entries. </li>
<li>contacts-save.php displays a form to add a new entry, and processes the submission. </li>
<li>contacts-delete.php deletes a specified entry. </li>
</ul>
<p>Begin with the first script and update <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c1">Listing 1</a> with some additional links, as in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c8">Listing 8</a>:</p>
<p><a name="c8"><b>Listing 8: Retrieving and displaying contacts</b></a></p>
<pre>&lt;!DOCTYPE html
  PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;Listing contacts&lt;/title&gt;
    &lt;style&gt;
    body {
      font-family: Verdana;
    }
    div.name {
      color: red;
      text-decoration: none;
      font-weight: bolder;
    }
    div.entry {
      display: inline;
      float: left;
      width: 450px;
      height: 150px;
      border: 2px solid;
      margin: 10px;
      padding: 5px;
    }
    td {
      vertical-align: top;
    }
    span.links {
      float: right;
    }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h2&gt;Contacts&lt;/h2&gt;

    &lt;?php
    // load Zend Gdata libraries
    require_once 'Zend/Loader.php';
    Zend_Loader::loadClass('Zend_Gdata');
    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    Zend_Loader::loadClass('Zend_Http_Client');
    Zend_Loader::loadClass('Zend_Gdata_Query');
    Zend_Loader::loadClass('Zend_Gdata_Feed');

    // set credentials for ClientLogin authentication
    $user = &quot;user@gmail.com&quot;;
    $pass = &quot;guessme&quot;;

    try {
      // perform login and set protocol version to 3.0
      $client = Zend_Gdata_ClientLogin::getHttpClient(
        $user, $pass, 'cp');
      $gdata = new Zend_Gdata($client);
      $gdata-&gt;setMajorProtocolVersion(3);

      // perform query and get feed of all results
      $query = new Zend_Gdata_Query(
        'http://www.google.com/m8/feeds/contacts/default/full');
      $query-&gt;maxResults = 0;
      $query-&gt;setParam('orderby', 'lastmodified');
      $query-&gt;setParam('sortorder', 'descending');
      $feed = $gdata-&gt;getFeed($query);

      // display number of results
      ?&gt;

      &lt;h2&gt;&lt;?php echo $feed-&gt;title; ?&gt;&lt;/h2&gt;
      &lt;div&gt;
      &lt;?php echo $feed-&gt;totalResults; ?&gt; contact(s) found.
      &lt;/div&gt;

      &lt;?php
      // parse feed and extract contact information
      // into simpler objects
      $results = array();
      foreach($feed as $entry){
        $obj = new stdClass;
        $obj-&gt;edit = $entry-&gt;getEditLink()-&gt;href;
        $xml = simplexml_load_string($entry-&gt;getXML());
        $obj-&gt;name = (string) $entry-&gt;title;
        $obj-&gt;orgName = (string) $xml-&gt;organization-&gt;orgName;
        $obj-&gt;orgTitle = (string) $xml-&gt;organization-&gt;orgTitle; 

        foreach ($xml-&gt;email as $e) {
          $obj-&gt;emailAddress[] = (string) $e['address'];
        }

        foreach ($xml-&gt;phoneNumber as $p) {
          $obj-&gt;phoneNumber[] = (string) $p;
        }
        foreach ($xml-&gt;website as $w) {
          $obj-&gt;website[] = (string) $w['href'];
        }

        $results[] = $obj;
      }
    } catch (Exception $e) {
      die('ERROR:' . $e-&gt;getMessage());
    }
    ?&gt;

    &lt;div&gt;
    &lt;a href=&quot;contacts-save.php&quot;&gt;Add a new contact&lt;/a&gt;
    &lt;/div&gt;    

    &lt;?php
    // display results
    foreach ($results as $r) {
    ?&gt;
    &lt;div class=&quot;entry&quot;&gt;
      &lt;div class=&quot;name&quot;&gt;&lt;?php echo (!empty($r-&gt;name))
       ? $r-&gt;name : 'Name not available'; ?&gt;
        &lt;span class=&quot;links&quot;&gt;&lt;a href=&quot;contacts-delete.php?
         id=&lt;?php echo $r-&gt;edit; ?&gt;&quot;&gt;Delete&lt;/a&gt;&lt;/span&gt;
      &lt;/div&gt;
      &lt;div class=&quot;data&quot;&gt;
        &lt;table&gt;
          &lt;tr&gt;
            &lt;td&gt;Organization:&lt;/td&gt;
            &lt;td&gt;&lt;?php echo $r-&gt;orgName; ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Email:&lt;/td&gt;
            &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;emailAddress); ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Phone:&lt;/td&gt;
            &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;phoneNumber); ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Web:&lt;/td&gt;
            &lt;td&gt;&lt;?php echo @join(', ', $r-&gt;website); ?&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;?php
    }
    ?&gt;

  &lt;/body&gt;
&lt;/html&gt;</pre>
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f4">Figure 4</a> illustrates the revised output.</p>
<p><a name="f4"><b>Figure 4. A Web page that lists contacts, with add and delete functions</b></a></p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/image4.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image4" border="0" alt="image4" src="http://moryadesigns.files.wordpress.com/2009/09/image4_thumb.jpg?w=378&#038;h=270" width="378" height="270" /></a> </p>
<p>You&#8217;ll see, from <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f4">Figure 4</a>, that there&#8217;s now an additional Delete link next to each entry. This link includes the entry ID, which is passed to the link target as a GET parameter. The target script reads this ID and deletes it using the technique outlined in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c5">Listing 5</a>. <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c9">Listing 9</a> shows what the code looks like:</p>
<p><a name="c9"><b>Listing 9: Deleting contacts</b></a></p>
<pre>&lt;!DOCTYPE html
  PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;Deleting contacts&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h2&gt;Delete Contact&lt;/h2&gt;    

    &lt;?php
    // load Zend Gdata libraries
    require_once 'Zend/Loader.php';
    Zend_Loader::loadClass('Zend_Gdata');
    Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
    Zend_Loader::loadClass('Zend_Http_Client');
    Zend_Loader::loadClass('Zend_Gdata_Query');
    Zend_Loader::loadClass('Zend_Gdata_Feed');

    // set credentials for ClientLogin authentication
    $user = &quot;user@gmail.com&quot;;
    $pass = &quot;guessme&quot;;

    if (empty($_GET['id'])) {
      die('ERROR: Missing ID');
    } 

    try {
      // perform login and set protocol version to 3.0
      $client = Zend_Gdata_ClientLogin::getHttpClient(
        $user, $pass, 'cp');
      // set GData delete headers
      $client-&gt;setHeaders('If-Match: *');
      $gdata = new Zend_Gdata($client);
      $gdata-&gt;setMajorProtocolVersion(3);

      // delete entry
      $gdata-&gt;delete($_GET['id']);
      echo 'Entry deleted';
    } catch (Exception $e) {
      die('ERROR:' . $e-&gt;getMessage());
    }
    ?&gt;
  &lt;/body&gt;
&lt;/html&gt;  </pre>
<p>That takes care of listing and removing entries. But what about adding them? <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c10">Listing 10</a> introduces another script that allows users to add new contacts through a Web form. It then uses the Zend library to construct the corresponding POST packet and save the data to the server:</p>
<p><a name="c10"><b>Listing 10: Adding new contacts</b></a></p>
<pre>&lt;!DOCTYPE html
  PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
  &lt;head&gt;
    &lt;title&gt;Adding new contacts&lt;/title&gt;
    &lt;style&gt;
    body {
      font-family: Verdana;
    }
    &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h2&gt;Add Contact&lt;/h2&gt;    

    &lt;?php if (!isset($_POST['submit'])) { ?&gt;
    &lt;form method=&quot;post&quot;
     action=&quot;&lt;?php echo htmlentities($_SERVER['PHP_SELF']); ?&gt;&quot;&gt;
      Name: &lt;br/&gt;
      &lt;input name=&quot;name&quot; type=&quot;text&quot; size=&quot;15&quot; /&gt;&lt;p/&gt;
      Email address(es): &lt;br/&gt;
      &lt;textarea name=&quot;email&quot; type=&quot;text&quot;&gt;&lt;/textarea&gt;&lt;p/&gt;
      Organization: &lt;br/&gt;
      &lt;input name=&quot;org&quot; type=&quot;text&quot; size=&quot;15&quot; /&gt;&lt;p/&gt;
      &lt;input name=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Save&quot; /&gt;
    &lt;/form&gt;    

    &lt;?php
    } else { 

      // check for required input
      if (empty($_POST['name'])) {
        die('ERROR: Missing name');
      } 

      if (empty($_POST['email'])) {
        die('ERROR: Missing email address');
      } 

      if (empty($_POST['org'])) {
        die('ERROR: Missing organization');
      } 

      // sanitize input and save to array
      $inputData['name'] = htmlentities($_POST['name']);
      $inputData['email'] = htmlentities($_POST['email']);
      $inputData['org'] = htmlentities($_POST['org']);

      // load Zend Gdata libraries
      require_once 'Zend/Loader.php';
      Zend_Loader::loadClass('Zend_Gdata');
      Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
      Zend_Loader::loadClass('Zend_Http_Client');
      Zend_Loader::loadClass('Zend_Gdata_Query');
      Zend_Loader::loadClass('Zend_Gdata_Feed');

      // set credentials for ClientLogin authentication
      $user = &quot;user@gmail.com&quot;;
      $pass = &quot;guessme&quot;;

      try {
        // perform login and set protocol version to 3.0
        $client = Zend_Gdata_ClientLogin::getHttpClient(
          $user, $pass, 'cp');
        $gdata = new Zend_Gdata($client);
        $gdata-&gt;setMajorProtocolVersion(3);

        // create new entry
        $doc  = new DOMDocument();
        $doc-&gt;formatOutput = true;
        $entry = $doc-&gt;createElement('atom:entry');
        $entry-&gt;setAttributeNS('http://www.w3.org/2000/xmlns/' ,
         'xmlns:atom', 'http://www.w3.org/2005/Atom');
        $entry-&gt;setAttributeNS('http://www.w3.org/2000/xmlns/' ,
         'xmlns:gd', 'http://schemas.google.com/g/2005');
        $doc-&gt;appendChild($entry);

        // add name element
        $name = $doc-&gt;createElement('gd:name');
        $entry-&gt;appendChild($name);
        $fullName = $doc-&gt;createElement('gd:fullName', $inputData['name']);
        $name-&gt;appendChild($fullName);

        // add email elements
        $arr = explode(',', $inputData['email']);
        foreach ($arr as $a) {
          $email = $doc-&gt;createElement('gd:email');
          $email-&gt;setAttribute('address', $a);
          $email-&gt;setAttribute('rel' ,'http://schemas.google.com/g/2005#work');
          $entry-&gt;appendChild($email);
        }

        // add org name element
        $org = $doc-&gt;createElement('gd:organization');
        $org-&gt;setAttribute('rel' ,'http://schemas.google.com/g/2005#work');
        $entry-&gt;appendChild($org);
        $orgName = $doc-&gt;createElement('gd:orgName', $inputData['org']);
        $org-&gt;appendChild($orgName);

        // insert entry
        $entryResult = $gdata-&gt;insertEntry($doc-&gt;saveXML(),
         'http://www.google.com/m8/feeds/contacts/default/full');
        echo 'The ID of the new entry is: ' . $entryResult-&gt;id;
      } catch (Exception $e) {
        die('ERROR:' . $e-&gt;getMessage());
      }
    }
    ?&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#c10">Listing 10</a> actually consists of two parts: a Web form, and the PHP code that processes the input submitted through the form. <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f5">Figure 5</a> illustrates what this form looks like.</p>
<p><a name="f5"><b>Figure 5. A Web form to add a new contact</b></a></p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/image5.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image5" border="0" alt="image5" src="http://moryadesigns.files.wordpress.com/2009/09/image5_thumb.jpg?w=406&#038;h=290" width="406" height="290" /></a> </p>
<p>Once the user enters a contact&#8217;s name, e-mail address, and organization into this form and submits it, the second half of the script swings into action. First, an HTTP client is initialized and used to open an authenticated connection to the Google Contacts Data API. Next, the input entered into the Web form is validated, and a new DOMDocument object is initialized to hold the data for the new entry. </p>
<p>The DOM methods in PHP then dynamically construct a new &lt;entry&gt;, and the <code>insertEntry()</code> method actually saves the entry to the Google servers. Once the entry is added, the API will return its unique ID, which displays to the user to indicate a successful operation.</p>
<p><a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f6">Figure 6</a> illustrates the output after successfully adding a new entry.</p>
<p><a name="f6"><b>Figure 6. The output after adding a new contact</b></a></p>
<p>&#160;</p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/image6.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image6" border="0" alt="image6" src="http://moryadesigns.files.wordpress.com/2009/09/image6_thumb.jpg?w=393&#038;h=281" width="393" height="281" /></a> </p>
<p>In the screen capture in <a href="http://www.ibm.com/developerworks/library/x-phpgooglecontact/index.html#f6">Figure 6</a>, some fields are masked in the confirmation message from Google. The message is in the format: <code>The ID of the new entry is http://www.google.com/m8/feeds/contacts/USER_ID/base/CONTACT_ID.</code></p>
<br />Posted in PHP Scripts Tagged: contact grabber, google, Google Contacts, null script, php, php script <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/170/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=170&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/24/integrate-your-php-application-with-google-contacts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/image1_thumb.jpg" medium="image">
			<media:title type="html">image1</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/image2_thumb.jpg" medium="image">
			<media:title type="html">image2</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/image3_thumb.jpg" medium="image">
			<media:title type="html">image3</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/image4_thumb.jpg" medium="image">
			<media:title type="html">image4</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/image5_thumb.jpg" medium="image">
			<media:title type="html">image5</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/image6_thumb.jpg" medium="image">
			<media:title type="html">image6</media:title>
		</media:content>
	</item>
		<item>
		<title>A Complete Delegate Example</title>
		<link>http://moryadesigns.wordpress.com/2009/09/22/a-complete-delegate-example/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/22/a-complete-delegate-example/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 04:34:00 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[.NET Scripts]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Delegate]]></category>
		<category><![CDATA[moryadesigns]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/2009/09/22/a-complete-delegate-example/</guid>
		<description><![CDATA[Posted in .NET Scripts Tagged: .net, ASP.NET, Delegate, moryadesigns<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=157&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="display:inline;float:none;margin:0;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:307fb3e3-62a5-43d3-a18d-13b2faa3c8b5" class="wlWriterEditableSmartContent">
<div><span style="text-align:center; display: block;"><a href="http://moryadesigns.wordpress.com/2009/09/22/a-complete-delegate-example/"><img src="http://img.youtube.com/vi/pfvXbA3-M-A/2.jpg" alt="" /></a></span></div>
</div>
<br />Posted in .NET Scripts Tagged: .net, ASP.NET, Delegate, moryadesigns <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=157&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/22/a-complete-delegate-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>
	</item>
		<item>
		<title>Events in C#</title>
		<link>http://moryadesigns.wordpress.com/2009/09/22/events-in-c/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/22/events-in-c/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 04:30:00 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[.NET Scripts]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.ner]]></category>
		<category><![CDATA[Events in C#]]></category>
		<category><![CDATA[moryadesigns]]></category>
		<category><![CDATA[moryadesigns@gmail.com]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/2009/09/22/events-in-c/</guid>
		<description><![CDATA[Posted in .NET Scripts Tagged: .net, asp.ner, Events in C#, moryadesigns, moryadesigns@gmail.com<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=156&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div style="display:inline;float:none;margin:0;padding:0;" id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:e6798d92-8a75-4311-aafd-124086392217" class="wlWriterEditableSmartContent">
<div><span style="text-align:center; display: block;"><a href="http://moryadesigns.wordpress.com/2009/09/22/events-in-c/"><img src="http://img.youtube.com/vi/_rLrhVQEh_U/2.jpg" alt="" /></a></span></div>
</div>
<br />Posted in .NET Scripts Tagged: .net, asp.ner, Events in C#, moryadesigns, moryadesigns@gmail.com <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=156&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/22/events-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET MVC Overview (C#)</title>
		<link>http://moryadesigns.wordpress.com/2009/09/21/asp-net-mvc-overview-c/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/21/asp-net-mvc-overview-c/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:38:00 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[ASP.NET Scripts]]></category>
		<category><![CDATA[and UI logic]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET2.0]]></category>
		<category><![CDATA[business logic]]></category>
		<category><![CDATA[input logic]]></category>
		<category><![CDATA[moryadesigns@gmail.com]]></category>
		<category><![CDATA[MVC Framework]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/2009/09/21/asp-net-mvc-overview-c/</guid>
		<description><![CDATA[The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications. The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=155&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller. The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating MVC-based Web applications. The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the <b>System.Web.Mvc</b> namespace and is a fundamental, supported part of the <b>System.Web</b> namespace.</p>
<p>&#160;</p>
<p>MVC is a standard design pattern that many developers are familiar with. Some types of Web applications will benefit from the MVC framework. Others will continue to use the traditional ASP.NET application pattern that is based on Web Forms and postbacks. Other types of Web applications will combine the two approaches; neither approach excludes the other.    <br />The MVC framework includes the following components:</p>
<p><img alt="Invoking a controller action that expects a parameter value" src="http://static.asp.net/asp.net/images/mvc/21/image001.jpg" width="284" height="170" /> </p>
<p><strong>Figure 01</strong>: Invoking a controller action that expects a parameter value </p>
</p>
<ul>
<li><b>Models</b>. Model objects are the parts of the application that implement the logic for the application&#8217;s data domain. Often, model objects retrieve and store model state in a database. For example, a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in SQL Server. </li>
</ul>
<p>In small applications, the model is often a conceptual separation instead of a physical one. For example, if the application only reads a data set and sends it to the view, the application does not have a physical model layer and associated classes. In that case, the data set takes on the role of a model object. </p>
<ul>
<li><b>Views</b>. Views are the components that display the application&#8217;s user interface (UI). Typically, this UI is created from the model data. An example would be an edit view of a Products table that displays text boxes, drop-down lists, and check boxes based on the current state of a Products object. </li>
</ul>
<ul>
<li><b>Controllers</b>. Controllers are the components that handle user interaction, work with the model, and ultimately select a view to render that displays UI. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction. For example, the controller handles query-string values, and passes these values to the model, which in turn queries the database by using the values. </li>
</ul>
<p>The MVC pattern helps you create applications that separate the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements. The pattern specifies where each kind of logic should be located in the application. The UI logic belongs in the view. Input logic belongs in the controller. Business logic belongs in the model. This separation helps you manage complexity when you build an application, because it enables you to focus on one aspect of the implementation at a time. For example, you can focus on the view without depending on the business logic.    <br />In addition to managing complexity, the MVC pattern makes it easier to test applications than it is to test a Web Forms-based ASP.NET Web application. For example, in a Web Forms-based ASP.NET Web application, a single class is used both to display output and to respond to user input. Writing automated tests for Web Forms-based ASP.NET applications can be complex, because to test an individual page, you must instantiate the page class, all its child controls, and additional dependent classes in the application. Because so many classes are instantiated to run the page, it can be hard to write tests that focus exclusively on individual parts of the application. Tests for Web Forms-based ASP.NET applications can therefore be more difficult to implement than tests in an MVC application. Moreover, tests in a Web Forms-based ASP.NET application require a Web server. The MVC framework decouples the components and makes heavy use of interfaces, which makes it possible to test individual components in isolation from the rest of the framework.     <br />The loose coupling between the three main components of an MVC application also promotes parallel development. For instance, one developer can work on the view, a second developer can work on the controller logic, and a third developer can focus on the business logic in the model.</p>
<p>&#160;</p>
<h4><b>Deciding When to Create an MVC Application</b></h4>
<p>You must consider carefully whether to implement a Web application by using either the ASP.NET MVC framework or the ASP.NET Web Forms model. The MVC framework does not replace the Web Forms model; you can use either framework for Web applications. (If you have existing Web Forms-based applications, these continue to work exactly as they always have.)    <br />Before you decide to use the MVC framework or the Web Forms model for a specific Web site, weigh the advantages of each approach. </p>
<h5>Advantages of an MVC-Based Web Application</h5>
<p>The ASP.NET MVC framework offers the following advantages:</p>
<ul>
<li>It makes it easier to manage complexity by dividing an application into the model, the view, and the controller. </li>
<li>It does not use view state or server-based forms. This makes the MVC framework ideal for developers who want full control over the behavior of an application. </li>
<li>It uses a Front Controller pattern that processes Web application requests through a single controller. This enables you to design an application that supports a rich routing infrastructure. For more information, see <a href="http://go.microsoft.com/fwlink/?LinkId=106357"><u>Front Controller</u></a> on the MSDN Web site. </li>
<li>It provides better support for test-driven development (TDD). </li>
<li>It works well for Web applications that are supported by large teams of developers and Web designers who need a high degree of control over the application behavior. </li>
</ul>
<h5>Advantages of a Web Forms-Based Web Application</h5>
<p>The Web Forms-based framework offers the following advantages:</p>
<ul>
<li>It supports an event model that preserves state over HTTP, which benefits line-of-business Web application development. The Web Forms-based application provides dozens of events that are supported in hundreds of server controls. </li>
<li>It uses a Page Controller pattern that adds functionality to individual pages. For more information, see <a href="http://go.microsoft.com/fwlink/?LinkId=106359"><u>Page Controller</u></a> on the MSDN Web site. </li>
<li>It uses view state or server-based forms, which can make managing state information easier. </li>
<li>It works well for small teams of Web developers and designers who want to take advantage of the large number of components available for rapid application development. </li>
<li>In general, it is less complex for application development, because the components (the <b>Page</b> class, controls, and so on) are tightly integrated and usually require less code than the MVC model. </li>
</ul>
<h4><b>Features of the ASP.NET MVC Framework</b></h4>
<p>The ASP.NET MVC framework provides the following features:</p>
<ul>
<li>Separation of application tasks (input logic, business logic, and UI logic), testability, and test-driven development (TDD) by default. All core contracts in the MVC framework are interface-based and can be tested by using mock objects, which are simulated objects that imitate the behavior of actual objects in the application. You can unit-test the application without having to run the controllers in an ASP.NET process, which makes unit testing fast and flexible. You can use any unit-testing framework that is compatible with the .NET Framework. </li>
<li>An extensible and pluggable framework. The components of the ASP.NET MVC framework are designed so that they can be easily replaced or customized. You can plug in your own view engine, URL routing policy, action-method parameter serialization, and other components. The ASP.NET MVC framework also supports the use of Dependency Injection (DI) and Inversion of Control (IOC) container models. DI allows you to inject objects into a class, instead of relying on the class to create the object itself. IOC specifies that if an object requires another object, the first objects should get the second object from an outside source such as a configuration file. This makes testing easier. </li>
<li>A powerful URL-mapping component that lets you build applications that have comprehensible and searchable URLs. URLs do not have to include file-name extensions, and are designed to support URL naming patterns that work well for search engine optimization (SEO) and representational state transfer (REST) addressing. </li>
<li>Support for using the markup in existing ASP.NET page (.aspx files), user control (.ascx files), and master page (.master files) markup files as view templates. You can use existing ASP.NET features with the ASP.NET MVC framework, such as nested master pages, in-line expressions (&lt;%= %&gt;), declarative server controls, templates, data-binding, localization, and so on. </li>
<li>Support for existing ASP.NET features. ASP.NET MVC lets you use features such as forms authentication and Windows authentication, URL authorization, membership and roles, output and data caching, session and profile state management, health monitoring, the configuration system, and the provider architecture. </li>
</ul>
<p> <font color="#666666"></font></p>
<br />Posted in ASP.NET Scripts Tagged: and UI logic, ASP.NET, ASP.NET2.0, business logic, input logic, moryadesigns@gmail.com, MVC Framework <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=155&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/21/asp-net-mvc-overview-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>

		<media:content url="http://static.asp.net/asp.net/images/mvc/21/image001.jpg" medium="image">
			<media:title type="html">Invoking a controller action that expects a parameter value</media:title>
		</media:content>
	</item>
		<item>
		<title>Improving Performance with Output Caching (C#)</title>
		<link>http://moryadesigns.wordpress.com/2009/09/21/improving-performance-with-output-caching-c/</link>
		<comments>http://moryadesigns.wordpress.com/2009/09/21/improving-performance-with-output-caching-c/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:08:00 +0000</pubDate>
		<dc:creator>moryadesigns</dc:creator>
				<category><![CDATA[ASP.NET Scripts]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET2.0]]></category>
		<category><![CDATA[Cache Profile]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[moryadesigns]]></category>
		<category><![CDATA[Web.Config]]></category>

		<guid isPermaLink="false">http://moryadesigns.wordpress.com/2009/09/21/improving-performance-with-output-caching-c/</guid>
		<description><![CDATA[The goal of this tutorial is to explain how you can dramatically improve the performance of an ASP.NET MVC application by taking advantage of the output cache. The output cache enables you to cache the content returned by a controller action. That way, the same content does not need to be generated each and every [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=154&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The goal of this tutorial is to explain how you can dramatically improve the performance of an ASP.NET MVC application by taking advantage of the output cache. The output cache enables you to cache the content returned by a controller action. That way, the same content does not need to be generated each and every time the same controller action is invoked.
<p>Imagine, for example, that your ASP.NET MVC application displays a list of database records in a view named Index. Normally, each and every time that a user invokes the controller action that returns the Index view, the set of database records must be retrieved from the database by executing a database query.
<p>If, on the other hand, you take advantage of the output cache then you can avoid executing a database query every time any user invokes the same controller action. The view can be retrieved from the cache instead of being regenerated from the controller action. Caching enables you to avoid performing redundant work on the server.<br />
<h4>Enabling Output Caching</h4>
<p>You enable output caching by adding an [OutputCache] attribute to either an individual controller action or an entire controller class. For example, the controller in Listing 1 exposes an action named Index(). The output of the Index() action is cached for 10 seconds.
<p><b>Listing 1 – Controllers\HomeController.cs</b>
<pre>using System.Web.Mvc;

namespace MvcApplication1.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        [OutputCache(Duration=10, VaryByParam="none")]
        public ActionResult Index()
        {
            return View();
        }

    }
}</pre>
<p>In the Beta versions of ASP.NET MVC, output caching does not work for a URL like <a href="http://www.mysite.com/">http://www.MySite.com/</a>. Instead, you must enter a URL like <a href="http://www.mysite.com/Home/Index">http://www.MySite.com/Home/Index</a>. </p>
<p>In Listing 1, the output of the Index() action is cached for 10 seconds. If you prefer, you can specify a much longer cache duration. For example, if you want to cache the output of a controller action for one day then you can specify a cache duration of 86400 seconds (60 seconds * 60 minutes * 24 hours).</p>
<p>There is no guarantee that content will be cached for the amount of time that you specify. When memory resources become low, the cache starts evicting content automatically.</p>
<p>The Home controller in Listing 1 returns the Index view in Listing 2. There is nothing special about this view. The Index view simply displays the current time (see Figure 1).</p>
<p><b>Listing 2 – Views\Home\Index.aspx</b>
<pre>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="MvcApplication1.Views.Home.Index" %&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
&lt;head runat="server"&gt;
    &lt;title&gt;Index&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div&gt;

    The current time is: &lt;%= DateTime.Now.ToString("T") %&gt;

    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<pre>&nbsp;</pre>
<p><b>Figure 1 – Cached Index view</b></p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/clip_image002_3.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image002_3" border="0" alt="clip_image002_3" src="http://moryadesigns.files.wordpress.com/2009/09/clip_image002_3_thumb.jpg?w=334&#038;h=212" width="334" height="212"></a> </p>
<p>&nbsp;</p>
<p>If you invoke the Index() action multiple times by entering the URL /Home/Index in the address bar of your browser and hitting the Refresh/Reload button in your browser repeatedly, then the time displayed by the Index view won’t change for 10 seconds. The same time is displayed because the view is cached.</p>
<p>It is important to understand that the same view is cached for everyone who visits your application. Anyone who invokes the Index() action will get the same cached version of the Index view. This means that the amount of work that the web server must perform to serve the Index view is dramatically reduced.</p>
<p>The view in Listing 2 happens to be doing something really simple. The view just displays the current time. However, you could just as easily cache a view that displays a set of database records. In that case, the set of database records would not need to be retrieved from the database each and every time the controller action that returns the view is invoked. Caching can reduce the amount of work that both your web server and database server must perform. </p>
<p>Don’t use the page &lt;%@ OutputCache %&gt; directive in an MVC view. This directive is bleeding over from the Web Forms world and should not be used in an ASP.NET MVC application.</p>
<h4>Where Content is Cached</h4>
<p>By default, when you use the [OutputCache] attribute, content is cached in three locations: the web server, any proxy servers, and the web browser. You can control exactly where content is cached by modifying the Location property of the [OutputCache] attribute. </p>
<p>You can set the Location property to any one of the following values:</p>
<blockquote>
<p>· Any</p>
<p>· Client</p>
<p>· Downstream</p>
<p>· Server</p>
<p>· None</p>
<p>· ServerAndClient</p>
</blockquote>
<p>By default, the Location property has the value Any. However, there are situations in which you might want to cache only on the browser or only on the server. For example, if you are caching information that is personalized for each user then you should not cache the information on the server. If you are displaying different information to different users then you should cache the information only on the client.</p>
<p>For example, the controller in Listing 3 exposes an action named GetName() that returns the current user name. If Jack logs into the website and invokes the GetName() action then the action returns the string “Hi Jack”. If, subsequently, Jill logs into the website and invokes the GetName() action then she also will get the string “Hi Jack”. The string is cached on the web server for all users after Jack initially invokes the controller action. </p>
<p><b>Listing 3 – Controllers\BadUserController.cs</b>
<pre>using System.Web.Mvc;
using System.Web.UI;

namespace MvcApplication1.Controllers
{
    public class BadUserController : Controller
    {
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public string GetName()
        {
            return "Hi " + User.Identity.Name;
        }
    }
}</pre>
<p>Most likely, the controller in Listing 3 does not work the way that you want. You don’t want to display the message “Hi Jack” to Jill.</p>
<p>You should never cache personalized content in the server cache. However, you might want to cache the personalized content in the browser cache to improve performance. If you cache content in the browser, and a user invokes the same controller action multiple times, then the content can be retrieved from the browser cache instead of the server.</p>
<p>The modified controller in Listing 4 caches the output of the GetName() action. However, the content is cached only on the browser and not on the server. That way, when multiple users invoke the GetName() method, each person gets their own user name and not another person’s user name.</p>
<p><b>Listing 4 – Controllers\UserController.cs</b>
<pre>using System.Web.Mvc;
using System.Web.UI;

namespace MvcApplication1.Controllers
{
    public class UserController : Controller
    {
        [OutputCache(Duration=3600, VaryByParam="none", Location=OutputCacheLocation.Client, NoStore=true)]
        public string GetName()
        {
            return "Hi " + User.Identity.Name;
        }
    }
}</pre>
<p>Notice that the [OutputCache] attribute in Listing 4 includes a Location property set to the value OutputCacheLocation.Client. The [OutputCache] attribute also includes a NoStore property. The NoStore property is used to inform proxy servers and browser that they should not store a permanent copy of the cached content.</p>
<h4>Varying the Output Cache</h4>
<p>In some situations, you might want different cached versions of the very same content. Imagine, for example, that you are creating a master/detail page. The master page displays a list of movie titles. When you click a title, you get details for the selected movie.</p>
<p>If you cache the details page, then the details for the same movie will be displayed no matter which movie you click. The first movie selected by the first user will be displayed to all future users.</p>
<p>You can fix this problem by taking advantage of the VaryByParam property of the [OutputCache] attribute. This property enables you to create different cached versions of the very same content when a form parameter or query string parameter varies.</p>
<p>For example, the controller in Listing 5 exposes two actions named Master() and Details(). The Master() action returns a list of movie titles and the Details() action returns the details for the selected movie.</p>
<p><b>Listing 5 – Controllers\MoviesController.cs</b>
<pre>using System.Linq;
using System.Web.Mvc;
using MvcApplication1.Models;

namespace MvcApplication1.Controllers
{
    public class MoviesController : Controller
    {
        private MovieDataContext _dataContext;

        public MoviesController()
        {
            _dataContext = new MovieDataContext();
        }

        [OutputCache(Duration=int.MaxValue, VaryByParam="none")]
        public ActionResult Master()
        {
            ViewData.Model = (from m in _dataContext.Movies
                              select m).ToList();
            return View();
        }

        [OutputCache(Duration = int.MaxValue, VaryByParam = "id")]
        public ActionResult Details(int id)
        {
            ViewData.Model = _dataContext.Movies.SingleOrDefault(m =&gt; m.Id == id);
            return View();
        }

    }
}</pre>
<p>The Master() action includes a VaryByParam property with the value “none”. When the Master() action is invoked, the same cached version of the Master view is returned. Any form parameters or query string parameters are ignored (see Figure 2).</p>
<p><b>Figure 2 – The /Movies/Master view</b></p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/clip_image004_3.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image004_3" border="0" alt="clip_image004_3" src="http://moryadesigns.files.wordpress.com/2009/09/clip_image004_3_thumb.jpg?w=467&#038;h=274" width="467" height="274"></a>  </p>
<p><b>Figure 3 – The /Movies/Details view</b></p>
<p>&nbsp;</p>
<p><a href="http://moryadesigns.files.wordpress.com/2009/09/clip_image006_3.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="clip_image006_3" border="0" alt="clip_image006_3" src="http://moryadesigns.files.wordpress.com/2009/09/clip_image006_3_thumb.jpg?w=445&#038;h=211" width="445" height="211"></a></p>
<p>The Details() action includes a VaryByParam property with the value “Id”. When different values of the Id parameter are passed to the controller action, different cached versions of the Details view are generated.</p>
<p>It is important to understand that using the VaryByParam property results in more caching and not less. A different cached version of the Details view is created for each different version of the Id parameter.</p>
<p>You can set the VaryByParam property to the following values:</p>
<blockquote>
<p>* = Create a different cached version whenever a form or query string parameter varies.</p>
<p>none = Never create different cached versions </p>
<p>Semicolon list of parameters = Create different cached versions whenever any of the form or query string parameters in the list varies</p>
</blockquote>
<h4>Creating a Cache Profile</h4>
<p>As an alternative to configuring output cache properties by modifying properties of the [OutputCache] attribute, you can create a cache profile in the web configuration (web.config) file. Creating a cache profile in the web configuration file offers a couple of important advantages.</p>
<p>First, by configuring output caching in the web configuration file, you can control how controller actions cache content in one central location. You can create one cache profile and apply the profile to several controllers or controller actions.</p>
<p>Second, you can modify the web configuration file without recompiling your application. If you need to disable caching for an application that has already been deployed to production, then you can simply modify the cache profiles defined in the web configuration file. Any changes to the web configuration file will be detected automatically and applied.</p>
<p>For example, the &lt;caching&gt; web configuration section in Listing 6 defines a cache profile named Cache1Hour. The &lt;caching&gt; section must appear within the &lt;system.web&gt; section of a web configuration file. </p>
<p><b>Listing 6 – Caching section for web.config</b>
<pre>&lt;caching&gt;
&lt;outputCacheSettings&gt;
    &lt;outputCacheProfiles&gt;
        &lt;add name="Cache1Hour" duration="3600" varyByParam="none"/&gt;
    &lt;/outputCacheProfiles&gt;
&lt;/outputCacheSettings&gt;
&lt;/caching&gt;</pre>
<p>The controller in Listing 7 illustrates how you can apply the Cache1Hour profile to a controller action with the [OutputCache] attribute.</p>
<p><b>Listing 7 – Controllers\ProfileController.cs</b>
<pre>using System;
using System.Web.Mvc;

namespace MvcApplication1.Controllers
{
    public class ProfileController : Controller
    {
        [OutputCache(CacheProfile="Cache1Hour")]
        public string Index()
        {
            return DateTime.Now.ToString("T");
        }
    }
}</pre>
<p>If you invoke the Index() action exposed by the controller in Listing 7 then the same time will be returned for 1 hour. </p>
<h4>Summary</h4>
<p>Output caching provides you with a very easy method of dramatically improving the performance of your ASP.NET MVC applications. In this tutorial, you learned how to use the [OutputCache] attribute to cache the output of controller actions. You also learned how to modify properties of the [OutputCache] attribute such as the Duration and VaryByParam properties to modify how content gets cached. Finally, you learned how to define cache profiles in the web configuration file. </p>
<br />Posted in ASP.NET Scripts Tagged: .net, ASP.NET, ASP.NET2.0, Cache Profile, caching, moryadesigns, Web.Config <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/moryadesigns.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/moryadesigns.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/moryadesigns.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/moryadesigns.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/moryadesigns.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/moryadesigns.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/moryadesigns.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/moryadesigns.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/moryadesigns.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/moryadesigns.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/moryadesigns.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/moryadesigns.wordpress.com/154/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/moryadesigns.wordpress.com/154/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/moryadesigns.wordpress.com/154/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=moryadesigns.wordpress.com&amp;blog=9072648&amp;post=154&amp;subd=moryadesigns&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://moryadesigns.wordpress.com/2009/09/21/improving-performance-with-output-caching-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/753cfc86ed504f7e05a6eceb0b0af7e6?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">moryadesigns</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/clip_image002_3_thumb.jpg" medium="image">
			<media:title type="html">clip_image002_3</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/clip_image004_3_thumb.jpg" medium="image">
			<media:title type="html">clip_image004_3</media:title>
		</media:content>

		<media:content url="http://moryadesigns.files.wordpress.com/2009/09/clip_image006_3_thumb.jpg" medium="image">
			<media:title type="html">clip_image006_3</media:title>
		</media:content>
	</item>
	</channel>
</rss>
