使用omniauth-linkedin进行教育,技能,联系

时间:2013-02-05 20:58:27

标签: ruby-on-rails-3.2 omniauth linkedin

我在Rails中使用omniauth-linkedin gem并尝试从'r_fullprofile'和'r_network'获取数据。

在omniauth.rb中:

  provider :linkedin, 'consumer_key', 'consumer_secret', 
       :scope => 'r_fullprofile r_emailaddress r_network', 
       :fields => ["id", "email-address", "first-name", "last-name", 
                   "headline", "industry", "picture-url", "public-profile-url", 
                   "location", "connections", "skills", "date-of-birth", "phone-numbers",        
                   "educations", "three-current-positions" ]

在控制器中:

render :text => request.env["omniauth.auth"].to_yaml

结果输出似乎只有'r_basicprofile'的数据。如何解析剩余的所需数据(例如“连接”,“技能”,“教育”)?

2 个答案:

答案 0 :(得分:0)

我在使用Devise的Omniauth时遇到了同样的问题。

我必须进行更改才能输入:fields => [...]进入花括号。

在你的情况下:

  provider :linkedin, 'consumer_key', 'consumer_secret', 
       {:scope => 'r_fullprofile r_emailaddress r_network', 
       :fields => ["id", "email-address", "first-name", "last-name", 
                   "headline", "industry", "picture-url", "public-profile-url", 
                   "location", "connections", "skills", "date-of-birth", "phone-numbers",        
                   "educations", "three-current-positions" ]}

希望这有帮助。

答案 1 :(得分:0)

不知道这是否会对您有所帮助,但现在某些字段的名称不同。我把它放在我的devise.rb上并且它有效:

 function handleFileSelect(evt) {

    var files = evt.target.files[0]; // FileList object
    console.log("name "+files.name);
    var reader = new FileReader();
    var zip = new JSZip(evt.target.result);
    for( var entryName in zip.files){
        console.log("name of files "+entryName.name);           
    }
 }

document.getElementById('files').addEventListener('change', handleFileSelect, false);

temp[1-*]_max现在是temp[1-*]_crit,请参阅Linkedin Documentation