Reputation:
Im using linkedin's JS api to get some user profile information. I have this in my header:
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: xxxxx
authorize: false
onload: getProfileData
</script>
And this is what i am using to pull the data:
<script type="text/JavaScript">
function getProfileData(){
IN.API.Profile("me").fields(["firstName","lastName","headline","summary"]) .result(function(result) {
alert JSON.stringify(result))
}
</script>
However (checking through firebug) I do not what i asked it for. Instead it does a get request for standard information:
https://api.linkedin.com/v1/people::(~):(id,first-name,last-name,headline,picture-url)
Anyone know what this issue could be or how to fix? Thanks in advance
Upvotes: 0
Views: 2489
Reputation: 10697
It looks like there are a number of errors in your code:
First, using authorize: false
with an onLoad callback will not work, as authorize: false requires the user to manually 'SignIn' for every page load, and the onLoad call takes that option out of their hands. Secondly, you have onload
in the bootstrap section, it should be onLoad
. The following will fix both of these:
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: xxxxx
authorize: true
onLoad: getProfileData
</script>
Additionally, you are missing a number of brackets, etc in the actual worker code - the following should work:
<script type="text/javascript">
function getProfileData() {
IN.API.Profile("me")
.fields(["firstName", "lastName", "headline", "summary"])
.result(function(result) {
alert(JSON.stringify(result));
});
}
</script>
Keep in mind, if you would like to get anything more than the basic fields, you will need to ask for permission from the user.
Upvotes: 1