1

任务:从 Gmail 中导入联系人。

我使用 gem Omnicontacts。

全接触.rb:

Rails.application.middleware.use OmniContacts::Builder do
  importer :gmail, ENV['API_KEY'], ENV['API_SECRET'], {:redirect_path => '/contacts/gmail/callback'}

我的控制器:

def callback
    provider = params[:importer]
    @contacts = request.env['omnicontacts.contacts']
    @user = request.env['omnicontacts.user']
    if @contacts.nil?
      session[:message] = {
          :text => "Sorry, we didn't find any of your friends at this time. Please try again later.",
          :type => 'notice'
      }
    else
    ...
end

我的路线.rb:

get '/contacts/:importer'  => 'contacts_importer#callback', as: :import_contacts
get '/contacts/:importer/callback' => 'contacts_importer#callback'
get '/contacts/failure' => 'contacts_importer#failure'

我按照文档https://github.com/Diego81/omnicontacts中的说明做所有事情

但是@contacts@user总是为零。

为什么?

4

0 回答 0