Visitor Counter

Wednesday, 14 January 2015

Bringing Contacts from Gmail, Yahoo and Hotmail

This post will help you, on the off chance that you are stuck in bringing or get contacts from Yahoo, Gmail and Hotmail. This is conceivable utilizing diamond 'contacts'.

So here I am posting my code, I know there are part of things and code accessible for this, yet this is the precise code which I am utilizing.

On the off chance that you are running an application or need to make another proceed, I am composing another application here however you can include it in your current code also.

open your summon or reassure provoke and go into your application catalog, here I am making new:

rails contact

this will make a specific set of records and registries in your application. Presently go into your index, before begin working any further make certain that you have introduced "contacts" jewel with the most recent form i.e 1.0.13, to introduce "contacts" sort :

for linux clients : sudo pearl introduce contacts

for windows : pearl introduce contacts

in the event that as of now have yet more established variant redesign it : sudo diamond overhaul contacts

Presently open your environemnt.rb document and underneath this line compose do |config|


oblige "contacts"

make sure to restart your server.

Presently open the controllers organizer and make this system in any controller in the event that you have or where you need to show this. For my situation I am composing this in my account_controller.rb

def invite_friends
#@user = User.find(params[:id])

def import
@users = User.find(params[:id])
@sites = {“gmail”  => Contacts::Gmail, “yahoo” => Contacts::Yahoo, “hotmail” => Contacts::Hotmail}
@contacts = @sites[params[:from]].new(params[:login], params[:password]).contacts
@users , @no_users = [], []
@contacts.each do |contact|
#if u = User.find(:first , :conditions => = ‘#{contact[1]}’ , :include =>[:user])
if u = User.find(:first , :conditions => “email = ‘#{contact[1]}'” )
@users << u
@no_users << {:name => contact[0] , :email => contact[1]}
respond_to do |format|
format.html {render :template => ‘shared/_contact_list’, :layout => false}
format.xml {render :xml => @contacts.to_xml}

before creating this two method, just be sure that you are giving the user id from invite_friends method to import method.

Open up your invite_friends.html.erb and paste this code :

<% form_tag :action => ‘import’, :id => @user do %>

<select name=”from” id=”from”>
<option value=””>Select Id</option>
<option value=”gmail”>Gmail</option>
<option value=”yahoo”>Yahoo</option>
<option value=”hotmail”>Hotmail</option>

<BR />
<p>Please Enter Your Email Address Below : <BR />
<input type=”text” name=”login”></p>
<p>Enter Your Password :<BR />
<input type=”password” name=”password”></p>

<p><h4>Note : we are not going to save your Password anywhere </h4></p>
<p><%= submit_tag ‘Find My Friends’ %>

<% end %>

Presently begin your server, open up firefox and sort the location (for my situation it is) : http://localhost:3000/account/invite_friends

Select any administration like Yahoo, Hotmail or Gmail give the relating username and Password and hit submit.

You will get a mistake message that missing format, to evacuate that make an envelope "imparted" in/application/sees/ and make another document name "_contact_list.html.erb" and glue the beneath code :

<% for i in @contacts %>

<input type="checkbox" name="email[]" id="email_<%= i %>" value="<%= i %>"/><%= i %><br>

<% end %>

this will help you to take further activities on brought email addresses, that is it.