<?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>Rockurchin&#039;s Adventures In Programming</title>
	<atom:link href="http://rockurchin.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://rockurchin.com/blog</link>
	<description></description>
	<lastBuildDate>Tue, 02 Aug 2011 16:57:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Princess Trivia Contest</title>
		<link>http://rockurchin.com/blog/2011/07/princess-trivia-contest/</link>
		<comments>http://rockurchin.com/blog/2011/07/princess-trivia-contest/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 16:51:02 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Project Launches]]></category>
		<category><![CDATA[Facebook Apps]]></category>
		<category><![CDATA[Ignited]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Princess Cruises]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=82</guid>
		<description><![CDATA[Just launched a Facebook competition for Princess Cruiselines. The application is a trivia contest featuring 20 daily questions. Answers are all based on destinations you can cruise to, and can be found on various Princess web properties. Each correct answer gets you another entry into the sweepstakes, and the winner gets a free cruise for two. This project is part [...]]]></description>
			<content:encoded><![CDATA[<p>Just launched a Facebook competition for Princess Cruiselines. The application is a trivia contest featuring 20 daily questions. Answers are all based on destinations you can cruise to, and can be found on various Princess web properties. Each correct answer gets you another entry into the sweepstakes, and the winner gets a free cruise for two. This project is part of my day job at Ignited, and I was responsible for all frontend and backend coding.</p>
<p>Check it out here: <a href="http://apps.facebook.com/princess_trivia" title="Princess Trivia" target="_blank">http://apps.facebook.com/princess_trivia</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2011/07/princess-trivia-contest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redondo Beach Lobster Festival</title>
		<link>http://rockurchin.com/blog/2011/07/redondo-beach-lobster-festival/</link>
		<comments>http://rockurchin.com/blog/2011/07/redondo-beach-lobster-festival/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 16:25:02 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Project Launches]]></category>
		<category><![CDATA[Champ Creative]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Freelance]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Smarty]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=78</guid>
		<description><![CDATA[Just launched the completely redesigned website for Redondo Beach&#8217;s Lobster Festival. The site was designed by Champ Creative and is powered by my custom CMS. I was responsible for all coding (front end html/js/css and backend PHP/MySQL). You can see it here: http://lobsterfestival.com]]></description>
			<content:encoded><![CDATA[<p>Just launched the completely redesigned website for Redondo Beach&#8217;s Lobster Festival. The site was designed by Champ Creative and is powered by my custom CMS. I was responsible for all coding (front end html/js/css and backend PHP/MySQL). You can see it here: <a href="http://lobsterfestival.com">http://lobsterfestival.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2011/07/redondo-beach-lobster-festival/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Root Access On Amazon S3 Linux Instance</title>
		<link>http://rockurchin.com/blog/2011/02/getting-root-access-on-amazon-s3-linux-instance/</link>
		<comments>http://rockurchin.com/blog/2011/02/getting-root-access-on-amazon-s3-linux-instance/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 21:49:11 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Amazon S3]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[root]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=65</guid>
		<description><![CDATA[Amazon now recommends you connect to new E2 server instances using the user &#8220;ec2-user&#8221;. That&#8217;s great but what about when you need to perform actions that require root permissions. I spent some time trying to figure out what the default root password is, but turns out you don&#8217;t actually need to know. Just do this: Root super powers will then [...]]]></description>
			<content:encoded><![CDATA[<p>Amazon now recommends you connect to new E2 server instances using the user &#8220;ec2-user&#8221;. That&#8217;s great but what about when you need to perform actions that require root permissions. I spent some time trying to figure out what the default root password is, but turns out you don&#8217;t actually need to know. Just do this:</p>
<pre class="brush: php; title: ; notranslate">sudo su - root </pre>
<p>Root super powers will then be yours.</p>
]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2011/02/getting-root-access-on-amazon-s3-linux-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Host key verification failed</title>
		<link>http://rockurchin.com/blog/2011/02/host-key-verification-failed/</link>
		<comments>http://rockurchin.com/blog/2011/02/host-key-verification-failed/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 21:38:35 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[amazon]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=74</guid>
		<description><![CDATA[My ssh connection to some Amazon instances stopped working after I moved around the elastic IP. I got a &#8220;Host key verification failed&#8221; error. The following fixed the problem. This removes the offending entry from ~/.ssh/known_hosts which was apparently causing ssh to fail.]]></description>
			<content:encoded><![CDATA[<p>My ssh connection to some Amazon instances stopped working after I moved around the elastic IP. I got a &#8220;Host key verification failed&#8221; error. The following fixed the problem.</p>
<pre class="brush: php; title: ; notranslate">ssh-keygen -R  servername</pre>
<p>This removes the offending entry from ~/.ssh/known_hosts which was apparently causing ssh to fail.</p>
]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2011/02/host-key-verification-failed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN on Drobo FS</title>
		<link>http://rockurchin.com/blog/2011/01/svn-on-drobo-fs/</link>
		<comments>http://rockurchin.com/blog/2011/01/svn-on-drobo-fs/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 06:18:03 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[commandline]]></category>
		<category><![CDATA[Drobo FS]]></category>
		<category><![CDATA[DroboApps]]></category>
		<category><![CDATA[NAS]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=70</guid>
		<description><![CDATA[I just got a new Drobo FS. First thing I wanted to do was use it for hosting SVN repositories of my freelance code. Here's how to get things up and running.]]></description>
			<content:encoded><![CDATA[<ul>
<li>Create a share called &#8220;svnrepos&#8221; using Drobo Control</li>
<li>Install SVN Drobo app from here:  http://drobo.jhah.net/apps/subversion/start</li>
<li>Ssh into your Drobo. Change directory to /mnt/DroboFS/Shares/DroboApps/subversion/bin</li>
<li>Create a repository by typing &#8220;./svnadmin create /mnt/DroboFS/Shares/svnrepos/RepoName</li>
<li>Before you can actually add anything to repos with your regular SVN client you need to set up user access. I&#8217;m going to go the quickest, easiest root.</li>
<li>Cd  to /mnt/DroboFS/Shares/svnrepos/RepoName/conf</li>
<li>Edit svnserve.conf. Uncomment the following lines:</li>
</ul>
<pre class="brush: plain; title: ; notranslate">
[general]
anon-access = read
auth-access = write
password-db = passwd
</pre>
<ul>
<li>Edit &#8220;passwd&#8221; file. Add myuser=mypassword and save.</li>
<li>Should be able to check things in and out now from  svn://myuser@192.168.1.10:3690/RepoName</li>
</ul>
<p>Now I need to figure out how to access my Drobo FS from outside my network&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2011/01/svn-on-drobo-fs/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Facebook Iframe Apps And Long Pages</title>
		<link>http://rockurchin.com/blog/2010/11/facebook-iframe-apps-and-long-pages/</link>
		<comments>http://rockurchin.com/blog/2010/11/facebook-iframe-apps-and-long-pages/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 18:10:35 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[iframes]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=57</guid>
		<description><![CDATA[When you create iframe apps there is some nice code that Facebook provides so that the iframe itself can automatically resize to fit the content without leaving ugly scrollbars. The problem is when you link from the bottom of a long page to a short page you are not taken to the top of that short page, so sometimes all you see if a blank white canvas until you manually scroll up.]]></description>
			<content:encoded><![CDATA[<p>When you create iframe apps there is some nice code that Facebook provides so that the iframe itself can automatically resize to fit the content without leaving ugly scrollbars.</p>
<pre class="brush: jscript; title: ; notranslate">
window.fbAsyncInit = function() {
      FB.Canvas.setAutoResize();
    }
</pre>
<p>The problem is when you link from the bottom of a long page to a short page you are not taken to the top of that short page, so sometimes all you see is a blank white canvas until you manually scroll up. The new javascript SDK does not appear to have any functions we can use to do this yet (the old one did!).  After much fruitless searching, I discovered a useful nugget of wisdom in this forum thread: <a href="http://forum.developers.facebook.net/viewtopic.php?id=32906">http://forum.developers.facebook.net/viewtopic.php?id=32906</a></p>
<p>The following javascript hack solves our problem nicely:</p>
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function($) {
		scrollTo(0,0);
	});

	function scrollTo(x,y){
		$(&quot;body&quot;).append('&lt;iframe id=&quot;scrollTop&quot; style=&quot;border:none;width:1px;height:1px;position:absolute;top:-10000px;left:-100px;&quot; src=&quot;http://static.ak.facebook.com/xd_receiver_v0.4.php?r=1#%7B%22id%22%3A0%2C%22sc%22%3Anull%2C%22sf%22%3A%22%22%2C%22sr%22%3A2%2C%22h%22%3A%22iframeOuterServer%22%2C%22sid%22%3A%220.957%22%2C%22t%22%3A0%7D%5B0%2C%22iframeInnerClient%22%2C%22scrollTo%22%2C%7B%22x%22%3A'+x+'%2C%22y%22%3A'+y+'%7D%2Cfalse%5D&quot; onload=&quot;$(\'#scrollTop\').remove();&quot;&gt;&lt;/iframe&gt;');
	}
</pre>
<p>The last piece of code assumes you are already including Jquery in your page.</p>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://rockurchin.com/blog/2010/11/closing-the-facebook-invite-widget/" title="Permanent link to Closing the Facebook Invite Widget">Closing the Facebook Invite Widget</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2010/11/facebook-iframe-apps-and-long-pages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Closing the Facebook Invite Widget</title>
		<link>http://rockurchin.com/blog/2010/11/closing-the-facebook-invite-widget/</link>
		<comments>http://rockurchin.com/blog/2010/11/closing-the-facebook-invite-widget/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 05:25:08 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[fbml]]></category>
		<category><![CDATA[invite widget]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=44</guid>
		<description><![CDATA[I recently worked on a Flash based Facebook application, so of course I needed to use the Facebook multi-friend-selector invite widget. The Facebook javascript SDK makes it fairly easy to launch the request dialog. You have to specify a url for the form action, and by default you are redirected to that url after the invite is sent. This is [...]]]></description>
			<content:encoded><![CDATA[<p>I recently worked on a Flash based Facebook application, so of course I needed to use the Facebook multi-friend-selector invite widget. The Facebook javascript SDK makes it fairly easy to launch the request dialog. You have to specify a url for the form action, and by default you are redirected to that url after the invite is sent. This is not what you want when you are running a flash site! Fortunately you can set a target on the request form, and because the form is inside an iframe you can make it submit to itself by specifying &#8220;target=_self&#8221;</p>
<pre class="brush: jscript; title: ; notranslate">
//Replace the ALL_CAPS variables with your own values
function invite(){
	FB.ui({
		  method:'fbml.dialog',
		  width:'750px',
		  fbml:'&lt;fb:request-form action=&quot;'ACTION_URL&quot; target=&quot;_self&quot; method=&quot;post&quot; invite=&quot;true&quot; type=&quot;Invite&quot; content=&quot;This is the message you friend will see &lt;fb:req-choice url=\'INVITE_ACCEPT_URL\' label=\'Accept\' /&gt;&quot; &lt;fb:multi-friend-selector showborder=&quot;false&quot; actiontext=&quot;REQUEST FORM TITLE&quot; email_invite=&quot;false&quot; import_external_friends=&quot;false&quot; /&gt; &lt;/fb:request-form&gt;'
		  });
}
</pre>
<p>This is great. But after form submits to itself the dialog shell is still open. You can call a javascript function in the parent page (where our flash is) from the action url where the contents of the iframe ended up at. Assuming we had a function called closeInviteWidget in our parent page we could do this:</p>
<pre class="brush: jscript; title: ; notranslate">
&lt;script&gt;parent.closeInviteWidget();&lt;/script&gt;
</pre>
<p>Then all we need to do inside closeInviteWidget is call the js needed to close the Facebook generated dialogs. Easy right? Would be if Facebook provided a close method for their fbml.dialog. The Facebook developer documention is notoriously crappy, so I may just be missing it but hours of searching did not help me find the close method. After some experimenting and examining the actual rendered html via firebug I got the following to work though (I have Jquery on my page btw):</p>
<pre class="brush: jscript; title: ; notranslate">
function closeInviteWidget(){
    $(&quot;.fb_dialog&quot;).hide();
}
</pre>
<p>If someone has a more sensible way to accomplish this please let me know.</p>
<p>I think docs for the multi-friend-selector have now been updated, but when I originally started messing with this they stated that if I wanted to stop the email invite options from appearing after the initial friend selector we just needed to add the following to the multi-friend-selector fbml tag</p>
<pre class="brush: jscript; title: ; notranslate">email_invite=&quot;false&quot;</pre>
<p>This did nothing at all as far as I could tell. No one else could get the email page to stop showing up either. Now I see an addtional attribute mentioned in the docs, and this one does the trick</p>
<pre class="brush: jscript; title: ; notranslate">import_external_friends=&quot;false&quot;</pre>
<p>Now if only they&#8217;d said that in the first place!</p>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://rockurchin.com/blog/2010/11/facebook-iframe-apps-and-long-pages/" title="Permanent link to Facebook Iframe Apps And Long Pages">Facebook Iframe Apps And Long Pages</a>  </li>
<li> <a href="http://rockurchin.com/blog/2010/10/facebook-application-gotchas/" title="Permanent link to Facebook Application Gotcha&#8217;s">Facebook Application Gotcha&#8217;s</a>  </li>
<li> <a href="http://rockurchin.com/blog/2010/10/getting-a-large-facebook-profile-image/" title="Permanent link to Getting A Large Facebook Profile Image">Getting A Large Facebook Profile Image</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2010/11/closing-the-facebook-invite-widget/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PHP Regular Expression Fun</title>
		<link>http://rockurchin.com/blog/2010/11/php-regular-expression-fun/</link>
		<comments>http://rockurchin.com/blog/2010/11/php-regular-expression-fun/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 16:35:33 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=38</guid>
		<description><![CDATA[There are already loads of resources on the interwebs explaining the purpose of regular expressions so no need to explain further here. (Well basically, they allow you to match and extract patterns of text from strings). I just want to document a few quick examples that I use a lot.]]></description>
			<content:encoded><![CDATA[<p>There are already loads of resources on the interwebs explaining the purpose of regular expressions so no need to explain further here. (Well basically, they allow you to match and extract patterns of text from strings). I just want to document a few quick examples that I use a lot.</p>
<h2>Finding Links</h2>
<p><strong>The Regular Expression:</strong></p>
<pre class="brush: php; title: ; notranslate">
preg_match_all(\&quot;/&lt;a\\s[^&gt;]*href=(\\\&quot;??)([^\\\&quot; &gt;]*?)\\\\1[^&gt;]*&gt;(.*)&lt;\\/a&gt;/siU\&quot;, $html, $matches)
1
&lt;p&gt;&lt;strong&gt;How I Use it:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Say we allowed people to post links in a comment form. We could use the reg exp to extract links not in our safe list, and make sure they always open in another tab instead of taking you away from our site.&lt;/p&gt;
1
 $safe_urls = array(\&quot;ignitedusa.com\&quot;,\&quot;ignitedla.com\&quot;,\&quot;yetiusa.com\&quot;);
 $regexp = \&quot;&lt;a\\s[^&gt;]*href=(\\\&quot;??)([^\\\&quot; &gt;]*?)\\\\1[^&gt;]*&gt;(.*)&lt;\\/a&gt;\&quot;;
 if(preg_match_all(\&quot;/$regexp/siU\&quot;, $html, $matches)) { /* $matches[2] = array of link addresses # $matches[3] = array of link text - including HTML code*/
    foreach($matches[2] as $k =&gt; $link){

        if (str_replace($safe_urls,\&quot;\&quot;,$link) == $link){
            if (str_replace(\&quot;mailto\&quot;,\&quot;\&quot;,$link) == $link){
                $html = str_replace(\'&lt;a href=\&quot;\' . $link . \'\&quot;\', \'&lt;a href=\&quot;\' . $link . \'\&quot; rel=\&quot;shadowbox[]\&quot; title=\&quot;\' . $matches[3][$k] . \'\&quot; target=\&quot;_blank\&quot;\', $html);
            }
        }
    }
  }
</pre>
<h2>Finding Images</h2>
<p><strong>The Regular Expression:</strong></p>
<pre class="brush: php; title: ; notranslate">
preg_match_all(\'/&lt;img[^&gt;]*&gt;/im\', $html, $imgTags);
</pre>
<p><strong>How I Use It:</strong></p>
<p>CMS users can&#39;t really be trusted to size their images sensibly for the web. They have infact been known to upload large files and just size in the rich text editor, meaning site viewers have to experience longer download times than necessary. Instead of banging one&#39;s head against the wall trying to teach them how to size things in an image editor and save for web, you can use the magic of reg expressions to pull out the images and replace with a link to a thumbnailer (I use phpThumb) that will size the image properly and cache it.</p>
<pre class="brush: php; title: ; notranslate">
function useCachedImages($html){  

	  global $CFG;
	  preg_match_all(\'/&lt;img[^&gt;]*&gt;/im\', $html, $imgTags); // get all images within the page
	  $img_tags = $imgTags[0];

	  //loop over the matches
	  foreach($img_tags as $img_tag)
	  {
		 preg_match(\'/src=\&quot;([^\&quot;]*)\&quot;/\', $img_tag, $src_match);   //gets the src string out of the img tag
		 $src = $src_match[1];
		 preg_match(\'/width=\&quot;([0-9]+)\&quot;/\', $img_tag, $w_match);  //height
		 $width = $w_match[1];
		 preg_match(\'/height=\&quot;([0-9]+)\&quot;/\', $img_tag, $h_match);  //width
		 $height= $h_match[1]; 

g = \&quot;&lt;img src=\\\&quot;\&quot; . $CFG-&gt;blog_url . \&quot;/libs/phpThumb/phpThumb.php?src=$src&amp;w=$width&amp;h=$height\\\&quot;&gt;\&quot;;
		//  echo $new_tag; exit;
		 $new_tags[] = $new_tag;
	  }
	  $ret = str_replace($img_tags,$new_tags,$html);
	  $ret = str_replace(\&quot;&lt;p class=\\\&quot;MsoNormal\\\&quot;&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;\&quot;,\&quot;\&quot;,$ret);  //Get rid of some annoying Microsoft crap too, for when they forget to use \&quot;Paste from Word\&quot;
	  return $ret;
}
</pre>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://rockurchin.com/blog/2010/10/getting-a-large-facebook-profile-image/" title="Permanent link to Getting A Large Facebook Profile Image">Getting A Large Facebook Profile Image</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2010/11/php-regular-expression-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting A Large Facebook Profile Image</title>
		<link>http://rockurchin.com/blog/2010/10/getting-a-large-facebook-profile-image/</link>
		<comments>http://rockurchin.com/blog/2010/10/getting-a-large-facebook-profile-image/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 18:17:32 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[graph api]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=28</guid>
		<description><![CDATA[The new graph api makes it really easy to show user profile pictures. It doesn't however give you your full size profile picture. Find out how to get that too.]]></description>
			<content:encoded><![CDATA[<p>The new graph api makes it really easy to show user profile pictures. If you know the id or object name of the user the following will render their profile picture:</p>
<pre class="brush: php; title: ; notranslate">
&lt;img src=&quot;https://graph.facebook.com/joey.choudhury/picture&quot;/&gt;
</pre>
<p>The default image returned is the small square size (50px x 50px). You can also specify a type argument to get different sizes. There are 3 options available: square (50&#215;50), small (50 pixels wide, variable height), and large (about 200 pixels wide, variable height):</p>
<pre class="brush: php; title: ; notranslate">
&lt;img src=&quot;https://graph.facebook.com/joey.choudhury/picture?type=square&quot;/&gt;
&lt;img src=&quot;https://graph.facebook.com/joey.choudhury/picture?type=small&quot;/&gt;
&lt;img src=&quot;https://graph.facebook.com/joey.choudhury/picture?type=large&quot;/&gt;
</pre>
<p>This would result in the following images being displayed:</p>
<div class="wp-caption alignnone" style="width: 60px"><img title="Facebook Small Square Profile Pic" src="https://graph.facebook.com/joey.choudhury/picture?type=square" alt="" width="50" height="50" /><p class="wp-caption-text">Square</p></div>
<div class="wp-caption alignnone" style="width: 60px"><img title="Facebook Small Profile Pic" src="https://graph.facebook.com/joey.choudhury/picture?type=small" alt="" width="50" height="38" /><p class="wp-caption-text">Small</p></div>
<div class="wp-caption alignnone" style="width: 190px"><img title="Facebook Large Profile Pic" src="https://graph.facebook.com/joey.choudhury/picture?type=large" alt="" width="180" height="135" /><p class="wp-caption-text">Large</p></div>
<p>So as you can see large isn&#8217;t actually that large. If you want to get the original version you&#8217;ll need to do a little more work. When ever you upload a new profile picture Facebook puts it in an album called &#8220;Profile Pictures&#8221;. The graph api lets you pull a list of a users&#8217; photo albums, so all we need to do is get the album list, look for &#8220;Profile Pictures&#8221; and grab the lastest image from that album. Using the PHP SDK you can do this:</p>
<pre class="brush: php; title: ; notranslate">
$albums = $facebook-&gt;api('/' . $user_id . '/albums');
foreach($albums['data'] as $album){
    if ($album['name'] == &quot;Profile Pictures&quot;){
        $photos = $facebook-&gt;api('/' . $album['id'] . '/photos');
        $profile_pic = $photos['data'][0]['source'];
       break;
    }
}
</pre>
<p>$profile_pic is the url to the largest version of the profile pic that Facebook saved. </p>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://rockurchin.com/blog/2010/10/facebook-application-gotchas/" title="Permanent link to Facebook Application Gotcha&#8217;s">Facebook Application Gotcha&#8217;s</a>  </li>
<li> <a href="http://rockurchin.com/blog/2010/11/php-regular-expression-fun/" title="Permanent link to PHP Regular Expression Fun">PHP Regular Expression Fun</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2010/10/getting-a-large-facebook-profile-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Facebook Application Gotcha&#8217;s</title>
		<link>http://rockurchin.com/blog/2010/10/facebook-application-gotchas/</link>
		<comments>http://rockurchin.com/blog/2010/10/facebook-application-gotchas/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 19:24:03 +0000</pubDate>
		<dc:creator>rockurchin</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[coding horrors]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://rockurchin.com/blog/?p=8</guid>
		<description><![CDATA[I've been building a few Facebook applications recently, and would like to share solutions to some things that caused me lots of headaches.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been building a few Facebook applications recently, and would like to share solutions to some things that caused me lots of headaches.</p>
<h1>Cookies Not Saving In Internet Explorer</h1>
<p>This one had me banging my head against the table for many hours on launch day. On one page of my app I needed to save a cookie to remember the user&#8217;s country. It worked on every single browser except damned Internet Explorer. Eventually I found out that IE (with medium privacy settings) does not let pages inside an iframe save cookies. This also messes with sessions. The solution? You need to implement a P3P header to specifically tell IE that you are allowing cookies inside an iframe. In php I added the following to my code before anything is output to the screen:</p>
<pre class="brush: php; title: ; wrap-lines: true; notranslate">

header('P3P:CP=&quot;IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT&quot;');
</pre>
<p>This alone solved all my issues. In case you were wondering, P3P stands for the Platform for Privacy Preferences Project. What the hell does it mean? See <a href="http://en.wikipedia.org/wiki/P3P" target="_blank">here</a>.</p>
<h1>Infinite Redirect Loop</h1>
<p>If you are hosting your application on a windows server without a valid SSL certificate your app may get stuck in an infinite redirect loop when trying to check for a valid facebook session. If you view the error log, or manage to make your code exit after the error you may see an error like this:</p>
<pre class="brush: php; title: ; wrap-lines: true; notranslate">

Fatal error: Uncaught CurlException: 60: SSL certificate problem, verify  that the CA cert is OK. Details: error:14090086:SSL  routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed thrown
</pre>
<p>Solution: Add the following 2 lines to Facebook PHP SDK class. In version 2.1.2 of the file, I added them right after line 112.</p>
<pre class="brush: php; first-line: 113; title: ; wrap-lines: true; notranslate">

CURLOPT_SSL_VERIFYPEER =&gt; false,
CURLOPT_SSL_VERIFYHOST =&gt; 2
</pre>
<div class="betterrelated"><p><strong>Related content:</strong></p>
<ol><li> <a href="http://rockurchin.com/blog/2010/10/getting-a-large-facebook-profile-image/" title="Permanent link to Getting A Large Facebook Profile Image">Getting A Large Facebook Profile Image</a>  </li>
<li> <a href="http://rockurchin.com/blog/2010/11/closing-the-facebook-invite-widget/" title="Permanent link to Closing the Facebook Invite Widget">Closing the Facebook Invite Widget</a>  </li>
</ol></div>]]></content:encoded>
			<wfw:commentRss>http://rockurchin.com/blog/2010/10/facebook-application-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

