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:
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:
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 !!
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