Skip to content
  • Home
  • About Puneet Pandey
  • Travel, Living & Lifestyle
  • Stackoverflow
  • Github

PUNEET PANDEY's WEBLOG

Where perfection meets intelligence

Add Facebook friends using ruby on rails

Fetch contacts from Facebook using Ruby on Rails

March 13, 2009June 15, 2009Puneet Pandey2 Comments

Volaaaa…. Finally I’ve got the way, how should I fetch contacts from facebook.. I hope everyone is looking for it..

Let me show you how would I do that.
Note: You can’t get your contacts email addresses using this post.
Mandatory Data:
[1] facebooker plugin
[2] Facebook developer application

Now how to do it let’s see:
Install facebooker plugin from Here into your rails application.
If you are done with that go to Facebook, if you have your account there sign-in and then search for developer application, add it if you haven’t added before. Below is the screenshot how you developer application looks like:

facebook_developer

Now here you can see a button “Set up New Application” click on that It will led you to a new application page like this:

new_fb_app

Give the name of your new application click on Agree and then “Save Changes”, Once your new application is created click on “Edit Settings” link on the right side of the center div.

It will drop you to a new page click on “Canvas” tab and give your “Callback URL” and “Canvas Page URL”.
NOTE: make sure those two fields are not blank and properly accepted by the facebook.

Now “back to My Applications”, you will find that you have following things:
[1] API Key
[2] Application Secret
[3] Callback URL
[4] Canvas URL

Now back into your rails application, after installing the plugin, you will find that a file facebooker.yml has been created for you in the config folder just open that and put all the 4 things inside that wherever it is needed.

Awesome Man!!!!! you are almost done.. just couple of steps short to see it in action

Create a controller for your rails application in my case it is:
ruby script/generate controller GettingStarted
open this file and paste the below lines:

class GettingStartedController < ApplicationController
ensure_authenticated_to_facebook

def index
@user = session[:facebook_session].user
@frnd=@user.friends!(:name, :interests, :status)
end
end

Now open up index.html.erb and paste the below code:
<input type=”textarea” name=”show_code” value=”

Disecting FaceBook With

body{padding:0px;margin:0px;font-family:verdana,Trebuchet MS; font-size:12px; background-color:#eee;}
p.rowA {background-color: #C6DB7C; color:#000000;width:400px; }
p.rowB {background-color: #457AA0;width:400px; }
p{margin:0px; padding:10px;}
#left{width:40%;border:1px solid #eee;float:left; padding:10px;}
#right{width:50%; border:1px solid #eee; float:right; padding:10px;color:white;}

Hey we got you !!

<img src=”” />


These are the people, you talking with?

<p class=””> <input type=”checkbox” name=”facebook_friends[]” id=”facebook_friends_” value=”” /> <%= “Friend: #{friend.name}
#{hash}
Interests: #{friend.interests}

” %>

” rows=”10″ cols=”20″>

create another file manually index.fbml.erb and paste the below code:

That’s it.. everything is finished.. start your server

Advertisement

Share this:

  • Click to email a link to a friend (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to print (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Skype (Opens in new window)

Like this:

Like Loading...
Ruby On RailsAdd Facebook friends using ruby on rails, Fetch facebook friends using rails, How to fetch contacts from facebook

Enter Keyword

Recent Posts

  • Connect to Box Explorer Component using Ruby on Rails
  • How to keep multiple versions of Elasticsearch on MacOS
  • [Rails 6] Using bootstrap with Asset Pipeline or Webpacker
  • Requests that take more than 60s to complete fails – ElasticBeanstalk
  • Configure Delayed Job with Elastic Beanstalk

Top Posts

  • Connect to Box Explorer Component using Ruby on Rails
  • How to keep multiple versions of Elasticsearch on MacOS
  • [Rails 6] Using bootstrap with Asset Pipeline or Webpacker
  • Requests that take more than 60s to complete fails - ElasticBeanstalk
  • Configure Delayed Job with Elastic Beanstalk

Recent Comments

Snehanshu Phukon on How to keep multiple versions…
Surendra on [Ruby] Fetching Emails from Mi…
bhagath on Fetch contacts from Facebook u…
Ashwin on [Ruby] Fetching Emails from Mi…
Puneet Pandey on [Ruby] Fetching Emails from Mi…

Blog Stats

  • 129,405 hits

I’m on Twitter

  • We are the nation of 139 crore and yet to find the best 11 jisko face karne mai opponents ka mutt nikal jaye.… twitter.com/i/web/status/1… 4 months ago
  • What is the maximum cashback you have received on CRED when you pay via CRED on partner's websites/apps (for exampl… twitter.com/i/web/status/1… 6 months ago
  • Dear #CRED you should change upto Rs 100 cashback to upto Rs 20 cashback on your partner sites. 18Rs is the max I’v… twitter.com/i/web/status/1… 6 months ago
  • @paytmbankcare All the nearby KYC centres are non operational. This list is false and misleading 10 months ago
  • It was a catch practice day for #TeamNewZealand and our boys did a great job in that #TeamIndia 1 year ago

I’m on Facebook

Puneet Pandey's Profile
Puneet Pandey's Facebook profile
Create Your Badge

Puneet on Linkedin

View Puneet Pandey's profile on LinkedIn

Archives

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 1,628 other subscribers

Pages

  • About Puneet Pandey
  • Ruby on Rails, iOS & PHP
  • Travel, Living & Lifestyle

Gravatar Profile

Puneet Pandey

Puneet Pandey

Name : Puneet Pandey Designation : Engineer, Blogger, Freelancer, Content Writer Height : 5 feet 11 inches Weight : 95 kgs Blood Group : A+ Career Interests : Ruby on Rails, Photography, Singing, Cooking, Travelling

Personal Links

  • A Weblog for All RoR Developers
  • Ruby on Rails Delivery Expert Blog
  • GitHub Profile

View Full Profile →

Find my Posts with these Tags

Ajax on Rails Auto Complete a simple example how to create scaffold on rails assign user a session basic scaffolding example create a login page in PHP Elastic Beanstalk How to create scaffold in rails how to send tweets from rails application how to validate a username and password in php Login script PHP login script php script to validate username and password pik rails Rails 3 Rails4 rails for beginners rails scaffold rails tweet ruby Ruby 1.9.2 Ruby on Rails ruby on rails auto select ruby on rails scaffold Ruby on Rails with Ajax Auto Select simple login page simple php user validation script twitter4r validates username and password validate user in php
Blog at WordPress.com.
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy
  • Follow Following
    • PUNEET PANDEY's WEBLOG
    • Join 1,536 other followers
    • Already have a WordPress.com account? Log in now.
    • PUNEET PANDEY's WEBLOG
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...
 

    %d bloggers like this: