Databasedotcom gem:根据会话ID检索用户信息

时间:2013-02-15 07:41:21

标签: ruby-on-rails ruby salesforce databasedotcom-gem

我正在使用databasedotcom gem与salesforce进行交互。我能够获得sObject(帐户,联系人,潜在客户)信息。任何人都可以告诉我如何通过传递salesforce会话ID来获取用户信息。

以下代码用于从salesforce获取帐户详细信息,但 我需要根据会话ID检索用户信息

client = Databasedotcom::Client.new("config/databasedotcom.yml")
client.authenticate :username => 'xxxxxx', :password => 'xxxxx'
client.sobject_module =SFDC_Models
client.materialize("Account")    
@acc = SFDC_Models::Account.all

1 个答案:

答案 0 :(得分:0)

经过几天的研究,结果是:token参数与Session ID相同。关于这一点的任何内容都没有记录,但希望它可以在将来帮助其他人。

class HomeController < ApplicationController
        def create
                @session_id = salesforce_params[ :sid ]
                location_split = salesforce_params[ :url ].split("/")
                @location = "http://" + location_split[2]     

                client = Databasedotcom::Client.new                    
                client.authenticate :token => @session_id, :instance_url => @location
                render :text => client.list_sobjects
        end

        private def salesforce_params
                params.permit( :sid, :url )
        end
end