【发布时间】:2015-03-05 17:28:37
【问题描述】:
我想通过 google 联系人 API 访问用户的联系人列表。
我已经设法获得令牌和刷新令牌,我现在正试图在我的 Rails 服务器上使用它。
google-api-client gem 似乎是要走的路,但我找不到要使用的 discovered_api。 Greg Baugues 提供了一个很棒的 tuto 来让 gmail API 正常工作。一般请求看起来像
client = Google::APIClient.new
client.authorization.access_token = user_token
service = client.discovered_api('gmail')
result = client.execute(
:api_method => service.users.labels.list,
:parameters => {'userId' => 'me'},
:headers => {'Content-Type' => 'application/json'})
pp JSON.parse(result.body)
但我找不到如何查询联系人。跑步
client.discovered_apis.each do |gapi|
puts "#{gapi.title} \t #{gapi.id} \t #{gapi.preferred} \n"
end
(来自here)现在显示与联系人相关的 API,我想知道这是否在 gem 的 alpha 版本中实现...
【问题讨论】:
-
您是否考虑过使用一些现成的解决方案,例如ruby google contacts api 或cloudsponge for ruby?
-
我找不到它们...所有搜索结果都指向 /developers.google.com。他们工作得很好,谢谢!
标签: ruby-on-rails google-api contacts