【发布时间】: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