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

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

问题描述

我使用 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- 确保您在您的应用中设置了电子邮件权限 (r_emailaddress) 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 Javascript API 获取电子邮件地址字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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