Linkedin login help

Hi Guys!

I am trying to use LinkedIn API to authenticate a user and get their member info to prefill a registration form.

Here’s the code I am using:


<script type="text/javascript" src="http://platform.linkedin.com/in.js">
  api_key: 92b7wk2jrrfl
  onLoad: onLinkedInLoad
  authorize: true
</script>

function onLinkedInLoad() {
	IN.Event.on(IN, "auth", onLinkedInAuth);
}
function onLinkedInAuth() {
	IN.API.Profile("me").result(displayProfiles);
}
function displayProfiles(profiles) {
	member = profiles.values[0];
	document.getElementById("first_name").value = member.firstName;
	document.getElementById("last_name").value = member.lastName;
}

It’s filling in my data but I have to refresh the page first for the data to be loaded. Is there some option to do this automatically?

Is that the code you’re actually using? If so, there are a couple of mistakes:

  • If your <script> tag loads an external file, it cannot also have JS embedded in it. Read more from John Resig: Degrading Script Tags
  • Your three functions aren’t wrapped in a <script> tag at all!

Sorry if it was misleading but the code is actually wrapped in tags on my site. However, the first point that you make about JS cannot be embedded if the tag loads an external URL - not sure that is true as this is code that I copied directly from the LinkedIn dev site. :confused:

Ah good, just me being an idiot :smiley:

Can you link to a live example?