如何将Rails的Linkedin客户端转换为Hash [英] How to convert Linkedin client in rails to Hash

查看:64
本文介绍了如何将Rails的Linkedin客户端转换为Hash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这样创建linkedin客户端.

I create linkedin client like this.

 client = LinkedIn::Client.new("3333", "rrrrrrr")
  client.authorize_from_access(session[:atoken], session[:asecret])

并获取这样的个人资料信息

and get profile information like this

 @profile = client.profile

当我打印"放入client.profile "之类的个人资料时,我得到了以下内容

when i print the profile like "puts client.profile", i get the following out put

 #<LinkedIn::Profile:0x4a77770 @doc=#<Nokogiri::XML::Document:0x253bb64 name="document" children=[#<Nokogiri::XML::Element:0x253b9fc name="pers
on" children=[#<Nokogiri::XML::Text:0x253b87c "\n  ">, #<Nokogiri::XML::Element:0x253b84c name="first-name" children=[#<Nokogiri::XML::Text:0x
253b684 "Anthony">]>, #<Nokogiri::XML::Text:0x253b5ac "\n  ">, #<Nokogiri::XML::Element:0x253b57c name="last-name" children=[#<Nokogiri::XML::
Text:0x253b3b4 "Raj S">]>, #<Nokogiri::XML::Text:0x253b2dc "\n  ">, #<Nokogiri::XML::Element:0x253b2ac name="headline" children=[#<Nokogiri::X
ML::Text:0x253b0e4 "Senior Software Engineer at AB Innovative Software Pvt. Ltd">]>, #<Nokogiri::XML::Text:0x253b00c "\n  ">, #<Nokogiri::XML:
:Element:0x253afdc name="site-standard-profile-request" children=[#<Nokogiri::XML::Text:0x253ae14 "\n    ">, #<Nokogiri::XML::Element:0x253ade
4 name="url" children=[#<Nokogiri::XML::Text:0x253ac1c "http://www.linkedin.com/profile?viewProfile=&key=78718913&authToken=XE_V&authType=name
&trk=api*a178337*s186521*">]>, #<Nokogiri::XML::Text:0x253ab44 "\n  ">]>, #<Nokogiri::XML::Text:0x253aa6c "\n">]>]>>

如何将其解析为hasmap或字符串?

How to parse this into a hasmap or to a string?

当我刚接触Rails时,请帮助我.

Pleas help me as i am new to rails.

推荐答案

  1. 将配置文件转换为xml 2.使用nokogiri进行操作
  1. Convert the profile to xml 2.manipulate with nokogiri

这篇关于如何将Rails的Linkedin客户端转换为Hash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆