【发布时间】:2015-08-12 07:59:33
【问题描述】:
我一直在使用 Omniauth 检索包含 Steam 用户名的环境。
输出如下:
<OmniAuth::AuthHash::InfoHash image="https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/d4/d45a66fee7932d270ec32d4457d865b485245cf1_medium.jpg" location="YT, CA" name="Daiki" nickname="Corybantic Walrus" urls=#<OmniAuth::AuthHash FriendList=#<URI::HTTP:0x0000000614f590 URL:http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=4A8837BF7A6C439681B57F4962D8B011&steamid=76561198128055024&relationship=friend> Profile="http://steamcommunity.com/id/hatterkiller/">> provider="steam" uid="76561198128055024">
我真的不知道如何在 Stack Overflow 中格式化它,所以这里有一个更清洁的 Pastebin。
我需要的信息在代码的<Omniauth::AuthHash::Infohash 里面。有没有办法使用 Ruby 检索用户名(昵称)并将其放入数组中?
有点像这样,但这仅适用于以前的输出格式:
auth = request.env['omniauth.auth']
session[:current_user] = { :nickname => auth.info['nickname'],
:image => auth.info['image'],
:uid => auth.uid }
【问题讨论】:
标签: ruby-on-rails ruby steam-web-api