<?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 Bit.ly Short URLs Using PHP: API Version&#160;3</title> <atom:link href="http://davidwalsh.name/bitly-api-php/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/bitly-api-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: Fred</title><link>http://davidwalsh.name/bitly-api-php#comment-32223</link> <dc:creator>Fred</dc:creator> <pubDate>Thu, 17 May 2012 10:09:48 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-32223</guid> <description>Solved the problem. I ended up calling it as XML rather than TXT.&lt;code&gt;
$bitly = get_bitly_short_url(&#039;YOUR URI&#039;,$username,$api_key,&#039;xml&#039;);
$xml = simplexml_load_file($bitly);
$short_url = $xml-&gt;data-&gt;url;
&lt;/code&gt;Then for that to work I made a tiny edit in the function so we don&#039;t need CURL.
&lt;code&gt;
function get_bitly_short_url($url,$login,$appkey,$format=&#039;txt&#039;) {
$connectURL = &#039;http://api.bit.ly/v3/shorten?login=&#039;.$login.&#039;&amp;apiKey=&#039;.$appkey.&#039;&amp;uri=&#039;.urlencode($url).&#039;&amp;format=&#039;.$format;
if ($format == &#039;xml&#039;)
return $connectURL;
return curl_get_result($connectURL);
}
&lt;/code&gt;Might help someone out there!</description> <content:encoded><![CDATA[<p>Solved the problem. I ended up calling it as XML rather than TXT.</p><p><code><br
/> $bitly = get_bitly_short_url('YOUR URI',$username,$api_key,'xml');<br
/> $xml = simplexml_load_file($bitly);<br
/> $short_url = $xml-&gt;data-&gt;url;<br
/> </code></p><p>Then for that to work I made a tiny edit in the function so we don&#8217;t need CURL.<br
/> <code><br
/> function get_bitly_short_url($url,$login,$appkey,$format='txt') {<br
/> $connectURL = 'http://api.bit.ly/v3/shorten?login='.$login.'&amp;apiKey='.$appkey.'&amp;uri='.urlencode($url).'&amp;format='.$format;<br
/> if ($format == 'xml')<br
/> return $connectURL;<br
/> return curl_get_result($connectURL);<br
/> }<br
/> </code></p><p>Might help someone out there!</p> ]]></content:encoded> </item> <item><title>By: Fred</title><link>http://davidwalsh.name/bitly-api-php#comment-32222</link> <dc:creator>Fred</dc:creator> <pubDate>Thu, 17 May 2012 09:45:19 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-32222</guid> <description>Ok, so I&#039;ve worked out where it&#039;s come from. The file that bit.ly outputs has the data on the first line, but then also outputs a blank second line.Any ideas how to remove it?</description> <content:encoded><![CDATA[<p>Ok, so I&#8217;ve worked out where it&#8217;s come from. The file that bit.ly outputs has the data on the first line, but then also outputs a blank second line.</p><p>Any ideas how to remove it?</p> ]]></content:encoded> </item> <item><title>By: Fred</title><link>http://davidwalsh.name/bitly-api-php#comment-32221</link> <dc:creator>Fred</dc:creator> <pubDate>Thu, 17 May 2012 09:41:00 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-32221</guid> <description>I&#039;m getting an ugly line return after outputting the function. Can&#039;t work out what&#039;s causing it? Any hints? :)</description> <content:encoded><![CDATA[<p>I&#8217;m getting an ugly line return after outputting the function. Can&#8217;t work out what&#8217;s causing it? Any hints? :)</p> ]]></content:encoded> </item> <item><title>By: Michael</title><link>http://davidwalsh.name/bitly-api-php#comment-31079</link> <dc:creator>Michael</dc:creator> <pubDate>Sun, 18 Mar 2012 02:49:13 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-31079</guid> <description>cURL is about 10x faster.</description> <content:encoded><![CDATA[<p>cURL is about 10x faster.</p> ]]></content:encoded> </item> <item><title>By: Tiago Celestino</title><link>http://davidwalsh.name/bitly-api-php#comment-28622</link> <dc:creator>Tiago Celestino</dc:creator> <pubDate>Mon, 23 Jan 2012 16:50:44 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-28622</guid> <description>The problem is resolved. The problem is my local server.</description> <content:encoded><![CDATA[<p>The problem is resolved. The problem is my local server.</p> ]]></content:encoded> </item> <item><title>By: Tiago Celestino</title><link>http://davidwalsh.name/bitly-api-php#comment-28615</link> <dc:creator>Tiago Celestino</dc:creator> <pubDate>Mon, 23 Jan 2012 12:09:47 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-28615</guid> <description>My code: http://pastebin.com/CYzuThRVThe result in browser is: bool(false)what&#039;s wrong?</description> <content:encoded><![CDATA[<p>My code: <a
href="http://pastebin.com/CYzuThRV" rel="nofollow">http://pastebin.com/CYzuThRV</a></p><p>The result in browser is: bool(false)</p><p>what&#8217;s wrong?</p> ]]></content:encoded> </item> <item><title>By: Koen Heltzel</title><link>http://davidwalsh.name/bitly-api-php#comment-27596</link> <dc:creator>Koen Heltzel</dc:creator> <pubDate>Tue, 15 Nov 2011 14:02:01 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-27596</guid> <description>Of course I meant to say: replace &quot;&amp; amp ;&quot; with &quot;&amp;&quot;</description> <content:encoded><![CDATA[<p>Of course I meant to say: replace &#8220;&amp; amp ;&#8221; with &#8220;&amp;&#8221;</p> ]]></content:encoded> </item> <item><title>By: Koen Heltzel</title><link>http://davidwalsh.name/bitly-api-php#comment-27595</link> <dc:creator>Koen Heltzel</dc:creator> <pubDate>Tue, 15 Nov 2011 14:00:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-27595</guid> <description>If you get the MISSING_ARG_APIKEY error using the above script, you have probably used the &quot;copy&quot; button to copy it to your clipboard, which adds html entity encoding. Replace &amp; with &amp; in the url&#039;s and the error should go away.</description> <content:encoded><![CDATA[<p>If you get the MISSING_ARG_APIKEY error using the above script, you have probably used the &#8220;copy&#8221; button to copy it to your clipboard, which adds html entity encoding. Replace &amp; with &amp; in the url&#8217;s and the error should go away.</p> ]]></content:encoded> </item> <item><title>By: Puneet</title><link>http://davidwalsh.name/bitly-api-php#comment-27179</link> <dc:creator>Puneet</dc:creator> <pubDate>Sat, 08 Oct 2011 09:46:13 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-27179</guid> <description>Hi, Thanks for this code. Just to add some. you can use wp_remote_fopen if you are running a WP blog. It will try with fopen first to retrieve the remote url and if it is not present it will switch over to curl.</description> <content:encoded><![CDATA[<p>Hi, Thanks for this code. Just to add some. you can use wp_remote_fopen if you are running a WP blog. It will try with fopen first to retrieve the remote url and if it is not present it will switch over to curl.</p> ]]></content:encoded> </item> <item><title>By: Dawson</title><link>http://davidwalsh.name/bitly-api-php#comment-24277</link> <dc:creator>Dawson</dc:creator> <pubDate>Tue, 31 May 2011 05:12:54 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4950#comment-24277</guid> <description>This may be true but not all servers allow file_get_contents() to be run, making CURL the real only solution.</description> <content:encoded><![CDATA[<p>This may be true but not all servers allow file_get_contents() to be run, making CURL the real only solution.</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.017 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-22 01:58:39 -->
