【问题标题】:get email address using linkedin API javascript SDK使用linkedin API javascript SDK获取电子邮件地址
【发布时间】:2016-12-20 15:57:03
【问题描述】:

我看到其他类似这样的讨论,但是我不知道如何从linkedin API 获取电子邮件地址,我在我的应用程序中启用了 r_emailaddress,这里我做了什么:

index.html:

    <!-- Linkedin login -->
 <script type="text/javascript" src="http://platform.linkedin.com/in.js">
    api_key: myapikey
    scope: r_basicprofile r_emailaddress
    onLoad:onLinkedInLoad
    authorize:true
    lang:en_US
 </script>  
 <script type="in/Login"></script>

这里是脚本:

    // 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);
    $('#nome').val(data.firstName);
    $('#cognome').val(data.lastName);
    $('#email').val(data.emailAddress);             
}

// 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.Raw("/people/~").result(onSuccess).error(onError);   
}

我想用 data.emailAdress 填充一个输入字段,但我在对象中没有它,有人知道该怎么做吗?谢谢!

【问题讨论】:

    标签: javascript api email linkedin


    【解决方案1】:

    至少我明白了!

    IN.API.Raw("/people/~:(id,firstName,lastName,emailAddress)?format=json")
        .result(onSuccess)
        .error(onError);
    

    【讨论】:

      【解决方案2】:

      Aya Magdy 在以下 SO 问题页面上提供了此问题的答案:

      How do I get email address field using the LinkedIn Javascript API?

      在您的情况下,您所要做的就是确保您在 Linkedin 应用页面的“默认应用程序权限”部分中检查了“r_emailaddress”。

      然后更改您的 getProfileData() 函数,使其如下所示:

      function getProfileData() {
         IN.API.Profile("me").fields("first-name", "last-name", "email-address").result(onSuccess).error(onError);
      }
      

      可以在此处找到有关 IN.API.Profile 函数的文档:

      https://developer-programs.linkedin.com/documents/inapiprofile

      【讨论】:

        猜你喜欢
        • 2014-06-01
        • 2013-11-19
        • 1970-01-01
        • 2018-08-01
        • 2019-02-28
        • 1970-01-01
        • 2023-03-05
        • 2012-08-19
        • 1970-01-01
        相关资源
        最近更新 更多