2015-09-07 25 views
0

想要可靠地获取用户的电子邮件,API文档中似乎没有关于LinkedIn的任何内容。我有鳕鱼工作抓住基本的配置文件,我已经尝试了我可以在网上找到额外的领域。但是这不会返回任何东西。下面是代码:从LinkedIn Javascript API可靠地获取电子邮件

<script type="text/javascript" src="//platform.linkedin.com/in.js"> 
    api_key: 11111111111 
    onLoad: onLinkedInLoad 
    authorize: true 
    scope: r_basicprofile 

    </script> 

<script type="text/javascript"> 
    // Setup an event listener to make an API call once auth is complete 
    function onLinkedInLoad() { 


     IN.Event.on(IN, "auth", getProfileData); 
    } 

    // Handle the successful return from the API call 
    function onSuccess(data) { 
     console.log(data); 

    } 

    // Handle an error response from the API call 
    function onError(error) { 
     console.log(error); 
    } 

    // Use the API call wrapper to request the member's basic profile data 
    function getProfileData() { 
    var fields = ['firstName', 'lastName', 'emailAddress']; 

     IN.API.Profile("me").fields(fields).result(onSuccess).error(onError); 
    } 
</script> 

和HTML:

<script type="in/Login"></script> 

我不知道是否有可能与当前版本返回电子邮件或电子邮件是用户设置,以便与每个用户不同而不同。

回答

0

你缺少r_emailaddress的范围:

<script type="text/javascript" src="//platform.linkedin.com/in.js"> 
     api_key: 11111111111 
     onLoad: onLinkedInLoad 
     authorize: true 
     scope: r_basicprofile r_emailaddress 
</script> 

还要确保你正在使用的字段正确的语法:

var fields = ['first-name', 'last-name', 'email-address']; 

最后检查在LinkedIn开发人员的应用程序设置,您授予r_emailaddress访问权限。

+0

是否有更新的字段 - 我认为这是'姓氏'等等 – disruptive

+0

它是固定的寿? –

相关问题