我如何使用LinkedIn的API的Javascript获取电子邮件地址字段? [英] How do I get email address field using the LinkedIn Javascript API?

查看:1421
本文介绍了我如何使用LinkedIn的API的Javascript获取电子邮件地址字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用LinkedIn的JavaScript API中的用户登录到我的应用程序,但是该API没有返回即使我要求对特定领域的许可的电子邮件地址。我包括API脚本如下:

I'm using the LinkedIn Javascript API to sign in users to my application, however the API is not returning the email address even though I'm requiring permission for that specific field. I'm including the API script as follows:

<script type="text/javascript" src="//platform.linkedin.com/in.js">
  api_key: API_KEY
  scope: r_fullprofile r_emailaddress
</script>

然后我包括登录的标记按钮:

then I'm including the Log In button in the markup:

<script type="in/Login" data-onAuth="onLinkedInAuth">

最后我有一个函数添加回调API响应:

and finally I have a function to add the callback for the API response:

function onLinkedInAuth() {
    var fields = ['first-name', 'last-name', 'email-address'];

    IN.API.Profile("me").fields(fields).result(function(data) {
        console.log(data);
    }).error(function(data) {
        console.log(data);
    });
};

我只得到了名字和姓氏,但API不返回的电子邮件域。

I'm only getting the First and Last Name but the API doesn't return the email field.

参考: https://developer.linkedin.com/documents/profile-fields#电子邮件

推荐答案

1 - 确保您在您的应用程序的 http://developer.linkedin.com/documents/authentication#granting

1- be sure you made email permission (r_emailaddress) in your app http://developer.linkedin.com/documents/authentication#granting

2 - 那么你可以使用这个

2- then you may use this

    <script type="text/javascript" src="http://platform.linkedin.com/in.js">
        api_key: key
        **onLoad: onLinkedInLoad**
        authorize: true
    </script>

    <script>



        function onLinkedInLoad() {
            IN.Event.on(IN, "auth", onLinkedInAuth);
        }

        // 2. Runs when the viewer has authenticated
        function onLinkedInAuth() {

            IN.API.Profile("me").fields("first-name", "last-name", "email-address").result(function (data) {
                console.log(data);
            }).error(function (data) {
                console.log(data);
            });
         }
</script>

希望这将帮助你:)
谢谢

hope this will help you :) thanks

这篇关于我如何使用LinkedIn的API的Javascript获取电子邮件地址字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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