2012-10-31 45 views
3

我目前正在开发一个需要用户通过LinkedIn登录的Rails网络应用程序。之后,我想在他/她的个人资料页面中嵌入Member Profile插件。LinkedIn API:如何为用户获取公共网址

为了实现这一点,我需要有公共URL,没有它的插件将无法正常工作。我已在LinkedIn登录上拥有完整个人资料许可r_fullprofile。但仍然无法找到提取公开网址的API。

有没有办法获得该网址?

回答

4

可以指定public-profile-url作为默认领域:

Rails.application.config.middleware.use OmniAuth::Builder do 
    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"] 
end 

,然后使用pengwynn LinkedIn宝石,你可以访问该网址,像这样:

client = LinkedIn::Client.new 
client.authorize_from_access("access_token", "access_token_secret") 
client.profile(:fields => ["public-profile-url"]) 
+0

谢谢您的精确和正确答案 – wael34218

+0

@ mccannf当使用[omniauth linkedin](https://github.com/decioferreira/omniauth-linkedin-oauth2)时,你如何获得访问令牌和令牌密钥? – Zamith

相关问题