【问题标题】:Import google contacts into a rails app将谷歌联系人导入 Rails 应用程序
【发布时间】:2013-12-27 14:18:47
【问题描述】:

我想将 google 联系人导入我的 rails 应用程序。

首先,Google 怎么敢在此处不包含 Ruby 的示例代码,

https://developers.google.com/google-apps/contacts/v3/?csw=1

其次,

如果你使用omnicontacts,https://github.com/Diego81/omnicontacts,它不会获取电话号码、城市、国家和其他东西(只有名字和姓氏)

第三,

如果你用谷歌搜索这个解决方案有点出名,http://rtdptech.com/2010/12/importing-gmail-contacts-list-to-rails-application/ 它对我不起作用。

第四,

使用omniauth gem 很容易导入谷歌日历事件,使用以下代码,

def action_after_callback
# After authenticating and hitting callback redirect url, which will route to this action.
@auth = request.env["omniauth.auth"]
#Use the token from the data to request a list of calendars
@token = @auth["credentials"]["token"]
client = Google::APIClient.new
client.authorization.access_token = @token
service = client.discovered_api('calendar', 'v3')
@result = client.execute(
  :api_method => service.events.insert,
  :parameters => {'calendarId' => 'primary'},
  :body => JSON.dump(event),
  :headers => {'Content-Type' => 'application/json'})
p @result.data
end

API DISCOVERY 不适用于我通过谷歌搜索得知的联系人。

那么有人帮助我最好的方法是什么?

【问题讨论】:

    标签: ruby-on-rails-3 import google-api google-contacts-api


    【解决方案1】:

    要获取所有联系人,您可以使用此 gem。

    https://github.com/aliang/google_contacts_api
    

    要获取单个联系人,您必须创建自己的服务。无论如何,在我提到的 gem 上创建它非常容易。

    【讨论】:

      【解决方案2】:

      我认为你应该更喜欢两颗宝石

      gem 'contacts'
      
      gem "omnicontacts`
      

      这很容易使用。

      参考网址:“https://github.com/cis-sourabh/gmail-contacts

      【讨论】:

      • OP 已经提到,omnicontacts“不会获取电话号码、城市、国家和其他东西(只有名字和姓氏)”。
      • 是的,omnicontacts 很简单,但没有导入电话号码,这很奇怪,并没有解决问题
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-01
      • 1970-01-01
      • 2017-03-18
      • 2015-10-25
      相关资源
      最近更新 更多