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

<channel>
	<title>Web Cash &#187; digg</title>
	<atom:link href="http://www.earn-web-cash.com/tag/digg/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.earn-web-cash.com</link>
	<description>Writing, Designing, and Making Money Online</description>
	<lastBuildDate>Sun, 04 Dec 2011 22:52:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Traffic Through Social Bookmarking</title>
		<link>http://www.earn-web-cash.com/2008/03/12/traffic-social-bookmarking/</link>
		<comments>http://www.earn-web-cash.com/2008/03/12/traffic-social-bookmarking/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 21:00:34 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Traffic]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[backlinks]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[social bookmarking]]></category>
		<category><![CDATA[stumbleupon]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/03/12/traffic-through-social-bookmarking/</guid>
		<description><![CDATA[Since Digg broke the scene years ago, website operators have looked to social bookmarking sites for help. They can be a great source of traffic, and they can also be a good source of backlinks for search engine optimization. For now, let&#8217;s stick with the traffic component. Can a social bookmarking site direct significant traffic [...]]]></description>
			<content:encoded><![CDATA[<p>Since Digg broke the scene years ago, website operators have looked to social bookmarking sites for help.  They can be a great source of traffic, and they can also be a good source of backlinks for search engine optimization.</p>
<p>For now, let&#8217;s stick with the traffic component.  Can a social bookmarking site direct significant traffic to your site, and is it worth your trouble to use them?<br />
<span id="more-176"></span></p>
<h4>Case One: Digg</h4>
<p>I&#8217;ve used a variety of social bookmarking sites while promoting this site &#8211; <a href="http://www.digg.com">Digg</a> being one of them.  Although some people have had tremendous success with Digg, I haven&#8217;t.  Most of the articles I Digg end up falling off the recently submitted page without too many Diggs.</p>
<p>In the past two months, I&#8217;ve had a dozen or so articles go up on Digg and I&#8217;ve only gotten 230 visits in return.  Most of those articles fall off the page after I&#8217;ve gotten a handful of visits.</p>
<p>Two articles were moderately successful.  <a href="http://www.earn-web-cash.com/2008/01/30/resize-images-php/">One article</a> I didn&#8217;t submit myself &#8211; a reader Dugg it and it promptly gained about 20 Diggs.  Despite its relative popularity, it didn&#8217;t bring in a whole lot of traffic.</p>
<p>Many of my articles are designed to garnish search engine traffic, so that may be why they don&#8217;t appeal to users scanning a bookmark list.  I did write <a href="http://www.earn-web-cash.com/2008/03/03/ubuntu-linux-myths/">another article</a> that focused more on an attention grabbing topic and less on search engine juju, and it did ok on Digg (~100 visits).</p>
<p>For whatever reason, Digg hasn&#8217;t been tremendously helpful for me.  I still leave it on the toolbar at the bottom &#8211; so that users can Digg an article they like &#8211; but I don&#8217;t actively submit many articles hoping for traffic.</p>
<h4>Case Two: dZone</h4>
<p>While browsing through social bookmarking sites to promote this site, I stumbled on <a href="http://www.dzone.com">dZone</a>.</p>
<p>At first I was excited.  It&#8217;s geared towards programmers and web developers, so my technically oriented articles should have done well.  Not so much.</p>
<p>Perhaps I haven&#8217;t found the right approach to take.  Some articles were probably too rudimentary for the savvy audience, while the more advanced articles didn&#8217;t have attention grabbing topics.</p>
<p>I&#8217;ve gotten a little bit of traffic from dZone &#8211; slightly less than from Digg &#8211; but it&#8217;s nothing to write home about.  I continue to use it every now and again to gain some backlinks, but I don&#8217;t count on it for traffic either.</p>
<h4>Case Three: Stumblupon</h4>
<p>Unlike Digg and dZone, <a href="http://www.stumbleupon.com">Stumble Upon</a> has done a great job.</p>
<p>One day I looked at my Google Analytics data, and I thought the thing had broken.  An average day at the time was about 2-300 visits &#8211; and this day showed as over 2,000 visits.</p>
<p>I went into the data and found out that one of articles was bringing in a ton of traffic from Stumble Upon.  The same article that brought in about 100 visits on Digg brought in over 2000 visits from Stumble Upon.</p>
<p>I wish I knew why it did that well, and how I could repeat it, but it just kind of happened.</p>
<p>Within the last few days, I&#8217;ve also noticed another page bringing in a decent amount of Stumble traffic.  For the past several days, it&#8217;s brought in 50+ visits each day.  I&#8217;m wondering how long that&#8217;ll last before the page gets shuffled out of the index.</p>
<h4>Bottom Line</h4>
<p>In terms of traffic, social bookmarking sites can be effective but they seem to be out of your own control.</p>
<p>I haven&#8217;t had a lot of luck with Digg and dZone, but I have had some good luck with StumbleUpon.</p>
<p>The best performing articles were submitted by other people, though &#8211; not me.  Maybe those people had fans that followed their bookmarks, leading more traffic to my site.  Or maybe it&#8217;s just luck of the draw.</p>
<p>My advice would be to leave a selection of &#8220;Share This&#8221; icons at the end of your article to encourage users to submit it to their favorite bookmarking sites.  However, don&#8217;t hold your breath and wait for a ton of traffic to come in.</p>
<p>In the meantime, consider the SEO benefits of social bookmarking sites.  We&#8217;ll come back to that another time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/03/12/traffic-social-bookmarking/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>How to Only Show the Digg Badge for Popular Posts</title>
		<link>http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/</link>
		<comments>http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 19:45:09 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Online Tools]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/</guid>
		<description><![CDATA[Digg can be a great source of traffic and recognition for tech related blogs. Some people take it to the extreme though, and show the &#8220;Digg This&#8221; badge on every article they write. As others have pointed out, this can be counter-productive. People don&#8217;t like to read articles that have just one Digg &#8211; they [...]]]></description>
			<content:encoded><![CDATA[<p>Digg can be a great source of traffic and recognition for tech related blogs.  Some people take it to the extreme though, and show the &#8220;Digg This&#8221; badge on every article they write.</p>
<p>As <a href="http://www.pronetadvertising.com/articles/why-the-digg-button-gets-you-buried-not-dugg11995.html">others have pointed out</a>, this can be counter-productive.  People don&#8217;t like to read articles that have just one Digg &#8211; they seem unpopular.</p>
<p>So here&#8217;s a solution: use the <a href="http://www.earn-web-cash.com/scripts-plugins-and-modules/wp-plugin-digg-badge/">Conditional &#8220;Digg This&#8221; WordPress Plugin</a> to only show the Digg Badge for articles that have a certain number of Diggs.<br />
<span id="more-129"></span></p>
<h5>Why Shouldn&#8217;t You Show the Digg Badge on Every Article?</h5>
<p>It&#8217;s easy enough to plaster the Digg Badge in your template or use a plug-in to add it to every post.  Most of your posts aren&#8217;t going to be popular though.  You&#8217;ll get at most one or two Diggs&#8230; nothing to write home about.</p>
<p>When a user opens your article, he or she might be impressed by &#8220;100 Diggs.&#8221;  He or she definitely won&#8217;t be impressed by &#8220;1 Digg.&#8221;  That&#8217;s a hint that your article wasn&#8217;t anything special &#8211; so why should the reader keep going?</p>
<h5>Using the Plugin to Only Show the Badge on Popular Articles</h5>
<p>The <a href="http://www.earn-web-cash.com/scripts-plugins-and-modules/wp-plugin-digg-badge/">Conditional Digg This</a> plug-in was designed to address this issue.</p>
<p>All you need to do is download the source code, upload it to your plugins directory, unpack the tar.gz, and click &#8220;Activate.&#8221;  You don&#8217;t need to modify any settings or insert anything into your template.  It&#8217;s all automated.</p>
<h5>How Does It Work?</h5>
<p>The basic concept behind the plugin is this:</p>
<ul>
<li>Load a story in your WordPress Blog</li>
<li>Check the Digg API to see how many diggs the article has</li>
<li>If the article has 10 or more diggs, show the badge&#8230;</li>
<li>Otherwise, leave it alone.</li>
</ul>
<p>Originally, I coded the plug-in to use a php function to access the API and check the number of Diggs each article had as it loaded.  This worked perfectly &#8211; but it took a while.  Sometimes, the API is slow to respond.  If the API took 8 seconds to spit back a response, that meant your page would take 8 extra seconds to load up.</p>
<p>Even if the API was responding quickly, this was a problem for the front page and category pages.  At best, the API takes about .25 to .5 seconds to respond &#8211; and with 10-15 checks on a page&#8230; you&#8217;re still waiting a good long time for the page to load.</p>
<h5>Load First, Check the API Later</h5>
<p>The solution I came up with was to use some nifty AJAX to perform the API checking behind the scenes.</p>
<p>The plug-in creates an AJAX request for each article.  It sends information to a php script which accesses the Digg API behind the scenes.  The page loads up instantly and AJAX will quietly do its thing.  When the response is ready, it&#8217;ll change the page to include the Digg This badge if necessary.</p>
<p>So, the next time you want to display a &#8220;Digg This&#8221; badge on your article, think about how many diggs your article has already.  Or, use the <a href="http://www.earn-web-cash.com/scripts-plugins-and-modules/wp-plugin-digg-badge/">Conditional &#8220;Digg This&#8221; WordPress Plugin</a> to automatically add a badge to your popular articles.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/18/digg-badge-popular-posts/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Digg API: Grabbing a Random Digg Story with PHP</title>
		<link>http://www.earn-web-cash.com/2008/02/16/digg-api-random-story/</link>
		<comments>http://www.earn-web-cash.com/2008/02/16/digg-api-random-story/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 00:46:22 +0000</pubDate>
		<dc:creator>Walkere</dc:creator>
				<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[Online Tools]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[digg]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.earn-web-cash.com/2008/02/16/digg-api-random-story/</guid>
		<description><![CDATA[I read about the Digg API the other day, and I thought it was about time I played around with it. There is a ton of cool stuff you can do with this. Basically, you send a request to the Digg server and it sends back whatever kind of information you want &#8211; category names, [...]]]></description>
			<content:encoded><![CDATA[<p>I read about the <a href="http://apidoc.digg.com/">Digg API</a> the other day, and I thought it was about time I played around with it.</p>
<p>There is a ton of cool stuff you can do with this.  Basically, you send a request to the Digg server and it sends back whatever kind of information you want &#8211; category names, recent diggs, recent stories, archived stories, etc.  You can read through the API to see everything you can do.</p>
<p>For now, we&#8217;ll focus on one nifty little trick &#8211; grabbing a random story from a given topic.<br />
<span id="more-122"></span></p>
<h5>Digg API Basics: How It Works</h5>
<p>Before we can build our script, we need to know the basics of how the Digg API works.</p>
<p>Your script sends an HTTP GET request to the Digg server.  This has three major parts.  If this is valid, the server sends you a response in one of several designated formats.  You can then parse it into use-able information and display it on your site.</p>
<p>The basic parts of the request are&#8230;</p>
<ul>
<li>Base Digg URL: http://services.digg.com</li>
<li>An <strong>Endpoint</strong>: i.e. /stories/topic/programming &#8211; this determines the type of information you&#8217;re getting back</li>
<li>A <strong>query string</strong>: i.e. ?count=5&#038;offset=20</li>
</ul>
<p>For this tutorial, we&#8217;ll be working with the &#8220;Programming&#8221; topic because, well, it works with my site.  You can look at the list of topics on the API page and tailor this to your needs.</p>
<p>Therefore the URL we&#8217;ll be accessing is: http://services.digg.com/stories/topic/programming</p>
<h5>What Goes In the Query String</h5>
<p>To go along with this, we&#8217;re going to have to build a query string.  There are a few required elements (appkey, type) and some optional ones that we&#8217;ll also use (count, offset).</p>
<p>&#8220;appkey&#8221; is basically an ID tag associated with your application.  Digg uses this for statistical purposes.  You can set this equal to the URI of your website.</p>
<p>&#8220;type&#8221; describes the type of response you&#8217;ll get.  There are four response types, of which two are applicable for use in a PHP script.  We&#8217;re going to focus on the XML response and use SimpleXML to parse the information.  Therefore type should be set to &#8216;xml.&#8217;</p>
<p>&#8220;count&#8221; tells the server how many stories we want to fetch.  &#8220;offset&#8221; tells the server how many stories to skip before it starts fetching them.  The &#8220;offset&#8221; is going to allow us to fetch a random story.</p>
<h5>Building the Query String</h5>
<p>So how do we build the query string?  First, we need to turn each of our values into a parameter in the format <code>key=value</code>.  The value must also be url encoded.  Here&#8217;s how we do that in php.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$appkey</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.earn-web-cash.com'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$appkeyParam</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'appkey='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$appkey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We can then string together all these variables with ampersands (&#038;) in between.  We then place a ? in the beginning of the query string, attach it to our URL, and we&#8217;re good to go.</p>
<p>I wrote a short function I use to automatically build the query string from an array of values.  I create an empty array, store the value with a key equal to its parameter name, and then pass it through the function.  The function returns the full query string for me to use.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Example array:</span>
<span style="color: #666666; font-style: italic;">//    $params['appkey'] = 'http://www.earn-web-cash.com';</span>
<span style="color: #666666; font-style: italic;">//    $params['type'] = 'xml';</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> buildQuery <span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'?'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'?'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$query</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000088;">$query</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'='</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>One other minor task we need to do is set up a &#8220;user_agent&#8221; for PHP.  The Digg server wants to know who&#8217;s accessing it, so you need to define a &#8220;user_agent&#8221; value for your instance of PHP with the ini_set command.  You can call your application whatever you want, but it usually follows the format &#8211; Name/Version.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user_agent'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'RandomDiggStory/1.0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h5>Firing Off the Request and Getting a Response</h5>
<p>We should now be able to send our request, get a response, and use some information.</p>
<p>To get a random story, we&#8217;re actually going to have to send two requests.  The first is going to allow us to find out how many stories exist in the topic.  The second will actually fetch a random story.</p>
<p>To find out how many stories exist in the topic, we&#8217;re going to create our request with the following information.  The appkey doesn&#8217;t matter, the type will be xml, the count will be 0, and the offset doesn&#8217;t matter.</p>
<p>Once we build the entire url with the query string, we open that location with simplexml_load_file &#8211; and the response will automatically be placed in a SimpleXML object for us.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$params</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'appkey'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.earn-web-cash.com'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'xml'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//  We don't need an offset for this one</span>
&nbsp;
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> buildQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://services.digg.com/stories/topic/programming'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$reqUrl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$reqUrl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$xml</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Need to typecast, or it'll be an object</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">asXML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Look at the source code to see what you fetched</span></pre></div></div>

<p>The last line (echo $xml->asXML()) isn&#8217;t necessary &#8211; it&#8217;s just to give you an idea of the information you just fetched.  It isn&#8217;t a whole lot &#8211; but we didn&#8217;t ask for a whole lot.</p>
<p>The piece of information we wanted was the total number of stories in our topic.  That&#8217;s the &#8216;total&#8217; attribute of the &#8216;stories&#8217; element.  We fetched it with <code>$xml['total']</code> and stored it in the $total variable.</p>
<h5>Last Step: Fetching the Random Story</h5>
<p>With this information in hand, we can craft a new request and get our random story.  You can copy and paste the same information we used before, but make these changes to the <code>$params</code> array.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// We want one story</span>
<span style="color: #000088;">$params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'offset'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$total</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>By generating a random value for offset between 0 and the maximum, we&#8217;re effectively choosing one random story from the available list.</p>
<p>Now run the script again.  At the end, $xml should have one random story stored in it.  The story information is stored in the <code>story</code> child element, and we can access some of the information like this.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">story</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'link'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// the URL</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">story</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'submit_date'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// timestamp when it was submitted</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">story</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">story</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">description</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you browse through the source code of the xml you outputted, you&#8217;ll find all of the essential information about the story.  Now you can format it nicely and add it to your website.</p>
<p>In case you ran into trouble along the way, here&#8217;s the complete <a href='http://www.earn-web-cash.com/wp-content/uploads/2008/02/random-digg-article.txt' title='Random Digg Article Script'>source code</a> of the script.  You&#8217;ll need to go in and change the topic to your desired topic and set your own appkey, but otherwise it should be all set to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.earn-web-cash.com/2008/02/16/digg-api-random-story/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

