我看到了类似的其他讨论,但是我无法弄清楚如何从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填充输入字段,但是我没有在对象中输入它,有人知道该怎么办?谢谢!
最佳答案
我至少知道了!
IN.API.Raw("/people/~:(id,firstName,lastName,emailAddress)?format=json")
.result(onSuccess)
.error(onError);