<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Create Digg URLs Using&#160;PHP</title> <atom:link href="http://davidwalsh.name/create-digg-url-php/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/create-digg-url-php</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Tue, 22 May 2012 05:31:04 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Hemant Arora</title><link>http://davidwalsh.name/create-digg-url-php#comment-26927</link> <dc:creator>Hemant Arora</dc:creator> <pubDate>Mon, 19 Sep 2011 08:23:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2032#comment-26927</guid> <description>This script does not work anymore, can you please tell me how to post to digg using PHP. Thanks.</description> <content:encoded><![CDATA[<p>This script does not work anymore, can you please tell me how to post to digg using PHP. Thanks.</p> ]]></content:encoded> </item> <item><title>By: Keith</title><link>http://davidwalsh.name/create-digg-url-php#comment-9679</link> <dc:creator>Keith</dc:creator> <pubDate>Tue, 09 Jun 2009 17:28:04 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2032#comment-9679</guid> <description>How would I get this to link from an image?I have my own image, how would I get that image to link to the Auto-generated DIGG Url?Thanks,
Keith.</description> <content:encoded><![CDATA[<p>How would I get this to link from an image?</p><p>I have my own image, how would I get that image to link to the Auto-generated DIGG Url?</p><p>Thanks,<br
/> Keith.</p> ]]></content:encoded> </item> <item><title>By: Greg</title><link>http://davidwalsh.name/create-digg-url-php#comment-9300</link> <dc:creator>Greg</dc:creator> <pubDate>Tue, 19 May 2009 18:24:10 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2032#comment-9300</guid> <description>Very nice! For some reason I wasn&#039;t getting any return HTTP request - and the reason was because I didn&#039;t set the User Agent! Thanks for the tip!</description> <content:encoded><![CDATA[<p>Very nice! For some reason I wasn&#8217;t getting any return HTTP request &#8211; and the reason was because I didn&#8217;t set the User Agent! Thanks for the tip!</p> ]]></content:encoded> </item> <item><title>By: Adriaan</title><link>http://davidwalsh.name/create-digg-url-php#comment-8566</link> <dc:creator>Adriaan</dc:creator> <pubDate>Mon, 06 Apr 2009 13:44:57 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2032#comment-8566</guid> <description>Thanks, this is nice... I wonder how long tinyurl will last now that digg competes with them?</description> <content:encoded><![CDATA[<p>Thanks, this is nice&#8230; I wonder how long tinyurl will last now that digg competes with them?</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/create-digg-url-php#comment-8564</link> <dc:creator>David Walsh</dc:creator> <pubDate>Mon, 06 Apr 2009 12:54:32 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2032#comment-8564</guid> <description>&lt;p&gt;@Anthony Sterling:  I like the regex because it prevents the overhead of bringing in XML parsing.  In all honesty, not using a XML reader is probably safer.&lt;/p&gt;</description> <content:encoded><![CDATA[<p>@Anthony Sterling:  I like the regex because it prevents the overhead of bringing in XML parsing.  In all honesty, not using a XML reader is probably safer.</p> ]]></content:encoded> </item> <item><title>By: Anthony Sterling</title><link>http://davidwalsh.name/create-digg-url-php#comment-8561</link> <dc:creator>Anthony Sterling</dc:creator> <pubDate>Mon, 06 Apr 2009 12:43:28 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2032#comment-8561</guid> <description>Excellent David.However, maybe this would be better suited to an object to bring those depended functions together. Additionally, it maybe best to avoid all those ini&#095;set shenanigans and embrace the XML rather that RegEx&#039;n it.&lt;?php
#Object
class ShortDiggURL
{
protected $sAppKey;public function _&#095;construct($sAppKey)
{
$this-&gt;sAppKey = $sAppKey;
}public function getShortURLFor($sLongURL)
{
$rContext = stream&#095;context&#095;create(
array(
&#039;http&#039; =&gt; array(
&#039;timeout&#039;       =&gt;  15,
&#039;user&#095;agent&#039;    =&gt; &#039;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6&#039;
)
)
);
$oResponse = @new SimpleXMLElement(
file&#095;get&#095;contents(
sprintf(
&#039;http://services.digg.com/url/short/create?type=xml&amp;appkey=%s&amp;url=%s&#039;,
urlencode($this-&gt;sAppKey),
urlencode($sLongURL)
),
null,
$rContext
)
);
if($oResponse instanceof SimpleXMLElement)
{
return $oResponse-&gt;shorturl[&#039;short&#095;url&#039;];
}
return false;
}
}#Usage
$oShortDiggURL = new ShortDiggURL(&#039;http://davidwalsh.name&#039;);
echo $oShortDiggURL-&gt;getShortURLFor(&#039;http://davidwalsh.name/penetrated-diggnation&#039;);
?&gt; </description> <content:encoded><![CDATA[<p>Excellent David.</p><p>However, maybe this would be better suited to an object to bring those depended functions together. Additionally, it maybe best to avoid all those ini&#95;set shenanigans and embrace the XML rather that RegEx&#8217;n it.</p><p>&lt;?php<br
/> #Object<br
/> class ShortDiggURL<br
/> {<br
/> protected $sAppKey;</p><p> public function _&#95;construct($sAppKey)<br
/> {<br
/> $this-&gt;sAppKey = $sAppKey;<br
/> }</p><p> public function getShortURLFor($sLongURL)<br
/> {<br
/> $rContext = stream&#95;context&#95;create(<br
/> array(<br
/> &#8216;http&#8217; =&gt; array(<br
/> &#8216;timeout&#8217;       =&gt;  15,<br
/> &#8216;user&#95;agent&#8217;    =&gt; &#8216;Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6&#8242;<br
/> )<br
/> )<br
/> );<br
/> $oResponse = @new SimpleXMLElement(<br
/> file&#95;get&#95;contents(<br
/> sprintf(<br
/> &#8216;http://services.digg.com/url/short/create?type=xml&amp;appkey=%s&amp;url=%s&#8217;,<br
/> urlencode($this-&gt;sAppKey),<br
/> urlencode($sLongURL)<br
/> ),<br
/> null,<br
/> $rContext<br
/> )<br
/> );<br
/> if($oResponse instanceof SimpleXMLElement)<br
/> {<br
/> return $oResponse-&gt;shorturl['short&#95;url'];<br
/> }<br
/> return false;<br
/> }<br
/> }</p><p>#Usage<br
/> $oShortDiggURL = new ShortDiggURL(&#8216;http://davidwalsh.name&#8217;);<br
/> echo $oShortDiggURL-&gt;getShortURLFor(&#8216;http://davidwalsh.name/penetrated-diggnation&#8217;);<br
/> ?&gt;</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/create-digg-url-php#comment-8560</link> <dc:creator>David Walsh</dc:creator> <pubDate>Mon, 06 Apr 2009 12:27:24 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=2032#comment-8560</guid> <description>&lt;p&gt;Note:  My attempts with cURL were unsuccessful but that was likely a hosting provider issue.&lt;/p&gt;</description> <content:encoded><![CDATA[<p>Note:  My attempts with cURL were unsuccessful but that was likely a hosting provider issue.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.009 seconds using disk: basic
Object Caching 628/628 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-22 03:15:29 -->
