【发布时间】: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