0

我应该如何处理用户撤销我对其 LinkedIn 帐户的访问权限?我正在使用 Ruby on RailsOmniauth和gem Omniauth-LinkedInlinkedin后者包含oauthgem)。

我的控制器代码

if !@user[:lnk_token].nil?
  client = LinkedIn::Client.new("xxxx","xxxx")
  client.authorize_from_access(@user[:lnk_token].strip,@user[:lnk_access_token_secret].strip)
  @lnk = client.profile(:fields => ["picture-url", "positions", "educations"])
end
4

1 回答 1

0

使用简单的错误处理程序:

if !@user[:lnk_token].nil?
  client = LinkedIn::Client.new("xxxx","xxxx")
  client.authorize_from_access(@user[:lnk_token].strip,@user[:lnk_access_token_secret].strip)
  begin
    @lnk = client.profile(:fields => ["picture-url", "positions", "educations"])
  rescue
    @lnk = nil
  end
end

进一步阅读:http ://rubylearning.com/satishtalim/ruby_exceptions.html

于 2013-03-14T21:02:20.777 回答