I am trying to create a form that grabs values from the user's LinkedIn profile in order to make it easier to sign on. I am having trouble grabbing some of the fields.
When I try to auto populate my form I have no issues grabbing First Name, Last Name, LinkedIn ID, and Headline. When I try to grab other fields like location, previous jobs, and industry and error appears on the page (ie. "Error: industry is not defined"). Note: this application has full profile privileges. I have attached snippets of my code and the results in the links below. Any advice would be greatly appreciated.
Working Code: https://i.sstatic.net/BYyaH.png
Non Working Code (added industry field): https://i.sstatic.net/ounnW.png
Here is the code that is working
<script type="IN/Login">
<input type="text" value="<?js= firstName ?>" />
<input type="text" value="<?js= id ?>" />
</script>
In below script use ID
that is available from above script
<script type="IN/MemberData"
data-ids="`here_put_the_ID`"
data-fields="firstName,lastName,industry">
<ul>
<?js for (var member in $("*")) { ?>
<li><?js= $(member).firstName ?> <?js= $(member).lastName ?>
Industry : <?js= $(member).industry ?></li>
<?js } ?>
</ul>
</script>
the second way is to get information is
function callmeOnLoad(){
IN.API.Profile("me")
.fields("id", "firstName", "lastName", "pictureUrl", "publicProfileUrl","industry")
.result(function(result, metadata) {
setConnections(result.values, metadata);
});
}
function setConnections(connections) {
for (id in connections) {
console.log(connections[id].firstName+":"+connections[id].industry)
}
}