<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Facebook on Yang's Blog</title><link>https://blog.yangtheman.com/tags/facebook/</link><description>Recent content in Facebook on Yang's Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>© 2026 Yang Chung</copyright><lastBuildDate>Thu, 09 Feb 2012 09:47:05 +0000</lastBuildDate><atom:link href="https://blog.yangtheman.com/tags/facebook/index.xml" rel="self" type="application/rss+xml"/><item><title>Facebook Connect with Rails (using Omniauth and Devise) [Update]</title><link>https://blog.yangtheman.com/2012/02/09/facebook-connect-with-rails-omniauth-devise/</link><pubDate>Thu, 09 Feb 2012 09:47:05 +0000</pubDate><guid>https://blog.yangtheman.com/2012/02/09/facebook-connect-with-rails-omniauth-devise/</guid><description/></item><item><title>How to integrate Facebook Feed with a Rails app</title><link>https://blog.yangtheman.com/2009/09/09/integrating-facebook-feed-with-a-rails-app/</link><pubDate>Wed, 09 Sep 2009 07:17:28 +0000</pubDate><guid>https://blog.yangtheman.com/2009/09/09/integrating-facebook-feed-with-a-rails-app/</guid><description>&lt;p&gt;On Monday, I&amp;rsquo;ve gotten Facebook Feed publishing to work with my site, and it took about two hours including TV watching time. I could&amp;rsquo;ve done it faster if I actually paid a full attention. It was all possible, thanks to Chris Schmitt, who has an excellent &lt;a href="http://www.thoughtintomotion.com/2009/06/publish-feed-stories-with-facebooker-rails.html" target="_blank" rel="noreferrer"&gt;tutorial&lt;/a&gt; on his site.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Simply you first need to create a sub-class inherited from &lt;strong&gt;Facebooker::Rails::Publisher&lt;/strong&gt; inside a controller. In my case, I wanted to publish a feed when a new playground is added and an existing playground is edited, so it made a sense to put it in &lt;strong&gt;playgrounds&lt;/strong&gt; controller. &lt;strong&gt;publish_pg&lt;/strong&gt; takes objects and sets parameters, and &lt;strong&gt;publish_pg_template&lt;/strong&gt; creates a feed message based on those parameters.&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;class PlaygroundsController &amp;lt; ApplicationController
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[SNIP - other actions]
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; class FacebookPublisher &amp;lt; Facebooker::Rails::Publisher
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; def publish_pg_template
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; one_line_story_template &amp;#34;{*actor*} created/updated: {*pg_name*}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; short_story_template &amp;#34;{*actor*} created/updated: {*pg_name*} in {*pg_city*}, {*pg_state*}&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &amp;#34;Check out what {*actor*} said, and rate or add comments to help other parents!&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; end
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; def publish_pg(pg, facebook_session)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; send_as :user_action
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; from facebook_session.user
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; data :actor =&amp;gt; facebook_session.user.first_name, :pg_name =&amp;gt; pg.name, :pg_city =&amp;gt; pg.city, :pg_state =&amp;gt; pg.state, :pg_id =&amp;gt; pg.id
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; end
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; end
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;end&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;**&lt;/p&gt;</description></item><item><title>How to integrate Facebook Connect with a Rails app</title><link>https://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/</link><pubDate>Mon, 24 Aug 2009 05:36:59 +0000</pubDate><guid>https://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/</guid><description>&lt;p&gt;&lt;em&gt;Update: I have written up another post for using Devise and Omniauth, and you can find it &lt;a href="http://blog.yangtheman.com/2012/02/09/facebook-connect-with-rails-omniauth-devise/" target="_blank" rel="noreferrer"&gt;here&lt;/a&gt;. Facebooker is no longer maintained.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Top of my to-do list was to integrate Facebook Connect with my Rails app, since 1) there are A LOT of people using Facebook and 2) having to register to post or edit could be an obstacle in getting more users to use my site.&lt;/p&gt;
&lt;p&gt;I looked on the web for a while, and found a great example by Stuart Eccles at &lt;a href="http://www.madebymany.co.uk/tutorial-for-restful_authentication-on-rails-with-facebook-connect-in-15-minutes-00523" target="_blank" rel="noreferrer"&gt;Made by Many&lt;/a&gt;. It&amp;rsquo;s an awesome tutorial, but it&amp;rsquo;s for restful_authentication. I don&amp;rsquo;t use it, so I had to modify it a little bit. Also, I added a step to ask a user to pick a username. So the following instruction is basically modification of Stuart&amp;rsquo;s.&lt;/p&gt;
&lt;p&gt;Without further ado, let&amp;rsquo;s begin.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.&lt;/strong&gt; Setup Facebook Application page&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.1.&lt;/strong&gt; Go to this &lt;a href="http://www.facebook.com/developers/#/developers/createapp.php" target="_blank" rel="noreferrer"&gt;page&lt;/a&gt;, and enter a name for your application. I named mine &amp;ldquo;Playgrounds_R_Us&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.2.&lt;/strong&gt; Make a note of &lt;strong&gt;Application ID&lt;/strong&gt;, &lt;strong&gt;API Key&lt;/strong&gt;, and &lt;strong&gt;Secret&lt;/strong&gt;. You need it for &lt;strong&gt;facebooker.yml&lt;/strong&gt; later.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.3.&lt;/strong&gt; Next is &lt;strong&gt;Authentication&lt;/strong&gt; section. Here what&amp;rsquo;s important is &lt;strong&gt;Post-Authroize&lt;/strong&gt; and &lt;strong&gt;Post-Remove Callback URL&lt;/strong&gt;. They refer to a web page a user will be taken to after logging into and logging out of Facebook account. While testing, I left it at &amp;ldquo;http://127.0.0.1:3000&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.4.&lt;/strong&gt; I also used the same URL (http://127.0.0.1:3000) for &lt;strong&gt;Canvas Callback URL&lt;/strong&gt; in &lt;strong&gt;Canvas&lt;/strong&gt; section and &lt;strong&gt;Connect URL&lt;/strong&gt; in &lt;strong&gt;Connect&lt;/strong&gt; section.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1.5.&lt;/strong&gt; Then you are pretty much set with configuration on Facebook side.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2.&lt;/strong&gt; Get &lt;a href="http://github.com/mmangino/facebooker/tree/master" target="_blank" rel="noreferrer"&gt;facebooker&lt;/a&gt; plugin and install it. From your rails app root directory,&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ruby script/plugin install git://github.com/mmangino/facebooker.git&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description></item></channel></rss>