검색하는 동안 Contacts 플러그인을 발견했습니다.Ruby on Rails에서 Gmail, Yahoo, Hotmail, Twitter, Facebook 연락처 목록을 가져 오기 위해 주소록을 가져 오는 데 문제가 있습니다.
하지만 사용법에 따라 추가 정보 파일에 설명되어 있습니다. 연락처를 가져 오려면 사용자 이름과 암호가 필요합니다. 그러나 그것은 좋은 접근 방법이 아닙니다.
검색하는 동안 Contacts 플러그인을 발견했습니다.Ruby on Rails에서 Gmail, Yahoo, Hotmail, Twitter, Facebook 연락처 목록을 가져 오기 위해 주소록을 가져 오는 데 문제가 있습니다.
하지만 사용법에 따라 추가 정보 파일에 설명되어 있습니다. 연락처를 가져 오려면 사용자 이름과 암호가 필요합니다. 그러나 그것은 좋은 접근 방법이 아닙니다.
Mini FB plugin Facebook 로그인. 또한 사용자 연락처를 가져올 수도 있습니다. 그래서 Facebook 용으로 사용할 수 있습니다. Koala 내가 페이스 북을위한 솔루션을 가지고 여기에
페이스 북 친구에게
페이스 북 업데이트를 가져 오는 또 다른 솔루션입니다,하지만 난 그냥 나 페이스 북
<div id="facebook_invites" class="conclusion" style="width: 750px; text-align: center">
<a id="wall_post" href="#" style="font-size: 2em;">Post on your Wall</a><br/>
<a id="invite_friends" href="#" style="font-size: 1.5em;">Invite your Friends</a>
</div>
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
$('#wall_post').click(function() {
FB.init({
appId:'app_id', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'feed',
link: 'http://localhost:3000/',
picture: 'http://localhost:3000/',
description: 'abc is cool.',
name: 'abc.com'});
});
$('#invite_friends').click(function() {
FB.init({
appId:'app_id', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'apprequests',
message: 'abc is cool.'});
});
</script>
Google 업데이트
google developers guide에서 6,, 우리는 절 "모든 연락처 검색"을 가지고 있지만, 그 사이에 줄 서면 즉,이 -
주: 다른 사용자의 연락처를 가져가 연락처 API의 현재 버전에서 지원하지 않는 .
/*
* Retrieve all contacts
*/
// Create the contacts service object
var contactsService =
new google.gdata.contacts.ContactsService('GoogleInc-jsguide-1.0');
// The feed URI that is used for retrieving contacts
var feedUri = 'http://www.google.com/m8/feeds/contacts/default/full';
var query = new google.gdata.contacts.ContactQuery(feedUri);
// Set the maximum of the result set to be 50
query.setMaxResults(50);
// callback method to be invoked when getContactFeed() returns data
var callback = function(result) {
// An array of contact entries
var entries = result.feed.entry;
// Iterate through the array of contact entries
for (var i = 0; i < entries.length; i++) {
var contactEntry = entries[i];
var emailAddresses = contactEntry.getEmailAddresses();
// Iterate through the array of emails belonging to a single contact entry
for (var j = 0; j < emailAddresses.length; j++) {
var emailAddress = emailAddresses[j].getAddress();
PRINT('email = ' + emailAddress);
}
}
}
// Error handler
var handleError = function(error) {
PRINT(error);
}
// Submit the request using the contacts service object
contactsService.getContactFeed(query, callback, handleError);
구글 연락처에 대한 또 다른 단절 측 솔루션 : 구글에 대한 솔루션 :
here에서 CLIENT_ID 및 client_secret를 가져옵니다. 이 스크립트는 거친 스크립트로 완벽하게 작동합니다. 귀하의 필요에 맞게 수정하십시오.
require 'net/http'
require 'net/https'
require 'uri'
require 'rexml/document'
class ImportController < ApplicationController
def authenticate
@title = "Google Authetication"
client_id = "xxxxxxxxxxxxxx.apps.googleusercontent.com"
google_root_url = "https://accounts.google.com/o/oauth2/auth?state=profile&redirect_uri="+googleauth_url+"&response_type=code&client_id="+client_id.to_s+"&approval_prompt=force&scope=https://www.google.com/m8/feeds/"
redirect_to google_root_url
end
def authorise
begin
@title = "Google Authetication"
token = params[:code]
client_id = "xxxxxxxxxxxxxx.apps.googleusercontent.com"
client_secret = "xxxxxxxxxxxxxx"
uri = URI('https://accounts.google.com/o/oauth2/token')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data('code' => token, 'client_id' => client_id, 'client_secret' => client_secret, 'redirect_uri' => googleauth_url, 'grant_type' => 'authorization_code')
request.content_type = 'application/x-www-form-urlencoded'
response = http.request(request)
response.code
access_keys = ActiveSupport::JSON.decode(response.body)
uri = URI.parse("https://www.google.com/m8/feeds/contacts/default/full?oauth_token="+access_keys['access_token'].to_s+"&max-results=50000&alt=json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
contacts = ActiveSupport::JSON.decode(response.body)
contacts['feed']['entry'].each_with_index do |contact,index|
name = contact['title']['$t']
contact['gd$email'].to_a.each do |email|
email_address = email['address']
Invite.create(:full_name => name, :email => email_address, :invite_source => "Gmail", :user_id => current_user.id) # for testing i m pushing it into database..
end
end
rescue Exception => ex
ex.message
end
redirect_to root_path , :notice => "Invite or follow your Google contacts."
end
end
설정에 대한 스크린 샷.
Gmail 또는 특정 목적 : Gmail Contacts.
Yahoo 연락처의 경우, 알고있는 한 Contacts이 사용 된 것 같습니다. 누군가가 더 나은 대안을 가지고 있다면. 언급 해주세요.
트위터의 경우 나는 Twitter 보석을 적극 추천합니다.
Facebook의 경우 이미 Facebook 젬을 정렬했습니다. 그러나 저는 개인적으로 FB Graph을 사용합니다.
편집 :
흠, 나는 문서를 살펴 필요했습니다. 언급 된 예제가 없습니다. 아무데도 찾을 수있는 GmailContacts
를 사용하는 예를 에 대한
참조 샘플/authsub.rb : 그것은 언급하지 않지만. 아마도 작성자에게 보내는 빠른 이메일이 도움이 될까요?
또한 Contacts gem은 온라인에서 잘 설명되어있는 것으로 보입니다. 프로젝트 요구 사항을 충족시키는 방법을 찾을 수 있다면. 그런 다음이를 다른 이메일 제공 업체를위한 보편적 인 솔루션으로 사용할 수 있습니다.
연락처 검색에 대한 또 다른 방법은 유용 할 수있는 this입니다.
에서 Gmail이 아닌 어떤 보석을 사용하기 위해, 당신은이 보석 가치가 없어, 샘플 코드를 사용합니다. http://rtdptech.com/2010/12/importing-gmail-contacts-list-to-rails-application/를하지만 리디렉션 문제에 직면하고 현재의 것 -
https://gist.github.com/742461가 실제로 여기에 블로그 게시물을했다 -
여기 내 샘플 코드를 참조하십시오.
조인 테이블을 통해 초대 된 사용자를 추적해야합니다. 여기 FB.ui JS w/callback이 있습니다.
FB.ui({
method: 'apprequests',
title: t,
message: m
},
function(response) {
if (response) {
$.ajax({
type: 'POST',
url: "/invitation_requests/create",
data: { "requests[]" : response.request_ids },
timeout: 12500,
async : false, // This fixes an issue w/ IE
complete: function() {
$.cookie("latest_request_ids", response.request_ids.length);
window.location = "/users"
}
});
}
});
Gmail 연락처에 대한 예제 코드가 있습니다. 나는 시도했다. 그러나 didnt는 무엇이라도 얻는다. –
안녕하세요, Mohit, 제 편집 참조 –