<?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>Illuminati Karate, Inc. &#187; Facebook</title>
	<atom:link href="http://illuminatikarate.com/blog/tag/facebook/feed/" rel="self" type="application/rss+xml" />
	<link>http://illuminatikarate.com</link>
	<description>creative web design, development and marketing</description>
	<lastBuildDate>Fri, 03 Feb 2012 20:13:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Facebook Graph API requires Access Token for Feed Access</title>
		<link>http://illuminatikarate.com/blog/facebook-graph-api-requires-access-token-for-feed-access/</link>
		<comments>http://illuminatikarate.com/blog/facebook-graph-api-requires-access-token-for-feed-access/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 18:49:58 +0000</pubDate>
		<dc:creator>Richard Gabriel</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://illuminatikarate.com/?p=442</guid>
		<description><![CDATA[On June 3rd, Facebook updated the Graph API to require an access token to pull wall post data from public Facebook pages. This change can cause scripts to stop working, so here is a quick solution to pull wall post data from public Facebook pages with an access token. [...]]]></description>
			<content:encoded><![CDATA[<p>On June 3rd, Facebook <a href="http://developers.facebook.com/blog/post/510/">updated the Graph API</a> to require an access token to pull wall post data from public Facebook pages.  This change can cause scripts to stop working, so here is a quick solution to pull wall post data from public Facebook pages with an access token.<span id="more-442"></span></p>
<p>Consider the following code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p442code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4424"><td class="code" id="p442code4"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fetchUrl<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$ch</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_init"><span style="color: #990000;">curl_init</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <a href="http://www.php.net/curl_setopt"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <a href="http://www.php.net/curl_setopt"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <a href="http://www.php.net/curl_setopt"><span style="color: #990000;">curl_setopt</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #339933;">,</span> CURLOPT_TIMEOUT<span style="color: #339933;">,</span> <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000088;">$retData</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/curl_exec"><span style="color: #990000;">curl_exec</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <a href="http://www.php.net/curl_close"><span style="color: #990000;">curl_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ch</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
     <span style="color: #b1b100;">return</span> <span style="color: #000088;">$retData</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p442code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4425"><td class="code" id="p442code5"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$profile_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;1234567890&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'feed_data'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> fetchUrl<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://graph.facebook.com/<span style="color: #006699; font-weight: bold;">{$profile_id}</span>/feed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Before the recent changes, this was all you needed to load a Facebook page&#8217;s feed.  You could load a public page&#8217;s feed by simply pulling from graph.facebook.com/{profile_id}/feed.  With the recent changes you just have to make a small modification and you&#8217;re good to go.</p>
<p>Here is the updated code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p442code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p4426"><td class="code" id="p442code6"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$profile_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;1234567890&quot;</span><span style="color: #339933;">;</span>		
&nbsp;
<span style="color: #666666; font-style: italic;">//App Info, needed for Auth</span>
<span style="color: #000088;">$app_id</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0001234567890&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$app_secret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;abc123ebf123f3g5g6j&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//retrieve auth token</span>
<span style="color: #000088;">$authToken</span> <span style="color: #339933;">=</span> fetchUrl<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://graph.facebook.com/oauth/access_token?type=client_cred&amp;client_id=<span style="color: #006699; font-weight: bold;">{$app_id}</span>&amp;client_secret=<span style="color: #006699; font-weight: bold;">{$app_secret}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'feed_data'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> fetchUrl<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://graph.facebook.com/<span style="color: #006699; font-weight: bold;">{$profile_id}</span>/feed?<span style="color: #006699; font-weight: bold;">{$authToken}</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Be sure to use https instead of http, needed for OAuth.  You&#8217;ll also need to <a href="http://developers.facebook.com">create a simple Facebook app</a> to get an App ID and Secret key.  Once done, just swap out the variables in the above script for the proper values and you&#8217;re off to the races!</p>
]]></content:encoded>
			<wfw:commentRss>http://illuminatikarate.com/blog/facebook-graph-api-requires-access-token-for-feed-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Submitting a Contact Form via AJAX From Your Facebook Page</title>
		<link>http://illuminatikarate.com/blog/submitting-a-contact-form-via-ajax-from-your-facebook-page/</link>
		<comments>http://illuminatikarate.com/blog/submitting-a-contact-form-via-ajax-from-your-facebook-page/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 03:57:08 +0000</pubDate>
		<dc:creator>George Huger</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[FBJS]]></category>
		<category><![CDATA[FBML]]></category>

		<guid isPermaLink="false">http://illuminatikarate.com/blog/?p=297</guid>
		<description><![CDATA[We recently created a contact submission form on a client&#8217;s Facebook page, and were not satisfied with the default user experience. For starters, the form opened a new window, and there was no way to redirect the user back to a confirmation message on the Facebook page. We decided [...]]]></description>
			<content:encoded><![CDATA[<p>We recently created a contact submission form on a client&#8217;s Facebook page, and were not satisfied with the default user experience. For starters, the form opened a new window, and there was no way to redirect the user back to a confirmation message on the Facebook page. </p>
<p>We decided to submit the form via AJAX instead, and show the confirmation message directly on the Facebook page. This way the user would not have to leave the Facebook page, resulting in a smoother user experience. We couldn&#8217;t find a good explanation of how to do this on Google, so after figuring it out I decided to go ahead and write it up. </p>
<p>The following example will show you how to submit a basic contact form using AJAX from within your Facebook page. All HTML and Javascript that follows should be pasted directly into the &#8220;Edit FBML&#8221; screen on Facebook.</p>
<p><span id="more-297"></span>Here&#8217;s the example form HTML we&#8217;ll use for the rest of this article. It&#8217;s just two text fields (name and email) and a submit button:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p297code10'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p29710"><td class="code" id="p297code10"><pre class="html" style="font-family:monospace;">&lt;form action=&quot;http://mywebsite.com/form_submit.php&quot; method=&quot;post&quot;&gt;
     &lt;p&gt;
          &lt;label for=&quot;name&quot;&gt;Name:&lt;/label&gt;
          &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; /&gt;
     &lt;/p&gt;
     &lt;p&gt;
          &lt;label for=&quot;email&quot;&gt;Email:&lt;/label&gt;
          &lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; /&gt;
     &lt;/p&gt;
     &lt;button type=&quot;submit&quot; onclick=&quot;return submitAjaxForm();&quot;&gt;Submit&lt;/button&gt;
     &lt;p id=&quot;ajaxMessage&quot;&gt;&lt;/p&gt;
&lt;/form&gt;</pre></td></tr></table></div>

<p>There&#8217;s three things you should take note of:</p>
<ol>
<li>The form&#8217;s <b>action</b> attribute is set to a page on mywebsite.com, not facebook.com (replace mywebsite.com with your own domain)</li>
<li>The submit button has an onSubmit event that calls a function submitAjaxForm, which we&#8217;ll define shortly</li>
<li>At the end of the form is an empty paragraph tag. We&#8217;ll use this space to display messages to the user.</li>
</ol>
<p>On our server, form_submit.php is a simple PHP script that logs the submissions, and sends back a message for the user letting them know the submission was successful. It might look something like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p297code11'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p29711"><td class="code" id="p297code11"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
     log_submission<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Thank you for your submission!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Of course, your script will be more sophisticated than this one, and doesn&#8217;t have to be written in PHP. Its on your server, so you can handle logging the submission however you like. Just make sure the output is valid <a href="http://wiki.developers.facebook.com/index.php/FBML">FBML</a>.</p>
<p>With the form HTML added to your Facebook page and the logging script in place, the only thing left is adding the Javascript to submit the form via AJAX and show the confirmation message.</p>
<p class="note"><b>Note:</b> Facebook does not allow you to use any Javascript function you like, for security purposes. Instead they&#8217;ve created a library of Javascript functions for accessing the DOM, AJAX, and event binding called <a href="http://wiki.developers.facebook.com/index.php/FBJS">FBJS</a>. These functions are used in the example below.</p>
<p>We&#8217;ll now define the submitAjaxForm() function we referenced earlier in our submit button&#8217;s onSubmit event:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p297code12'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p29712"><td class="code" id="p297code12"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;&lt;!--</span>
<span style="color: #003366; font-weight: bold;">function</span> submitAjaxForm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span> 
	<span style="color: #006600; font-style: italic;">// declare a new FBJS AJAX object</span>
	<span style="color: #003366; font-weight: bold;">var</span> ajax <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Ajax<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	ajax.<span style="color: #660066;">responseType</span> <span style="color: #339933;">=</span> Ajax.<span style="color: #660066;">FBML</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// define a callback to handle the response from the server</span>
	ajax.<span style="color: #660066;">ondone</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> 
	<span style="color: #009900;">&#123;</span> 
		document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ajaxMessage'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setInnerFBML</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// let the user know we're sending the data	</span>
	document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ajaxMessage'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setInnerXHTML</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Submitting your information, please wait...'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// collect field values</span>
	<span style="color: #003366; font-weight: bold;">var</span> queryParams <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">'name'</span> <span style="color: #339933;">:</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'email'</span> <span style="color: #339933;">:</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'email'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	ajax.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://mywebsite.com/form_submit.php'</span><span style="color: #339933;">,</span> queryParams<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">//--&gt;&lt;/script&gt;</span></pre></td></tr></table></div>

<p><em>Note: The opening and closing HTML comments embedded in the Javascript are important, so leave them intact.</em></p>
<p>The example is fairly self explanatory, but here&#8217;s what&#8217;s happening:</p>
<ol>
<li>Declare a new Ajax object, which is one of the FBJS classes. We then set its response type to FBML (Ajax.RAW and Ajax.JSON are also accepted).</li>
<li>Define a callback function to handle the response from the server. In this case, our function simply takes the response from the server and displays it in the #ajaxMessage paragraph we defined earlier.</li>
<li>Update the user to let them know their data is being submitted using FBJS&#8217;s setInnerFBML function.</li>
<li>Collect the form field&#8217;s values into an array named queryParams, using FBJS&#8217;s getElementById and getValue functions. Although getElementById is similar to the standard Javascript function, it accounts for the random slugs Facebook injects into div id&#8217;s for security (View Source on a Facebook page and look at the div ID&#8217;s to see this in action).</li>
<li>Send the AJAX request, using FBJS&#8217; Ajax.post function. The second argument is optional, and should be an array containing the query parameters.</li>
<li>&#8220;return false;&#8221; prevents the form&#8217;s normal submit behavior</li>
</ol>
<p>That&#8217;s all there is to it! If you have any questions or if I should clarify a section, let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://illuminatikarate.com/blog/submitting-a-contact-form-via-ajax-from-your-facebook-page/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
	</channel>
</rss>

