user1517369
user1517369

Reputation: 41

LinkedIN Integration JS API

We are integrating with Linked IN to extract the users profile. Its working fine, but we notice in some Windows 7 / IE 9 machines, Linked IN pop up comes up and is blank. We see the below error in console.

Message: Object doesn't support property or method 'replace' Line: 861 Char: 17 Code: 0 URI: http://platform.linkedin.com/js/framework?v=0.0.2000-RC1.21420-1403&lang=en_US

Code Snippet Below

<script type="text/javascript" src="https://platform.linkedin.com/in.js?async=false" >
  api_key: tw6oqfav7ms1
  authorize:false  
</script> 

//We have a custom image for linkedIN, onclick of the same below code is called.
$("#mylinkedin").click(function () {
  IN.UI.Authorize().params({"scope":["r_fullprofile", "r_emailaddress","r_contactinfo"]}).place();
  IN.Event.on(IN, "auth", onLinkedInAuth);
});

function onLinkedInAuth() {    
    IN.API.Profile("me").fields([ "id","firstName", "location","lastName","skills","positions","educations","languages","phone-numbers","certifications","emailAddress","mainAddress"]).result(displayProfiles);
    IN.User.logout(); //After we take the data, we do a log out
    $.get("https://api.linkedin.com/uas/oauth/invalidateToken");
}

function displayProfiles(profiles) {
 //Access profile and process
 member = profiles.values[0]
 ...........
}

Upvotes: 2

Views: 2806

Answers (2)

user1517369
user1517369

Reputation: 41

Thanks for your response.I was able to figure the issue on my own. What we observed was in the Win7 machines with IE9, the Linked IN authorization Pop Up was blank. When I uncheck the "Enable Protected Mode" the pop up is coming up without any issues.

Upvotes: 2

Unpossible
Unpossible

Reputation: 10697

I haven't had a chance to test this, but to me it looks like you've introduced a race condition in your code, specifically, in onLinkedInAuth().

The call to IN.API.Profile() invokes an async call to LinkedIn that may not be complete by the time the JavaScript engine in the IN.User.logout() code.

I would change the code to the following to see if this resolves the issue:

IN.API.Profile("me")
  .fields([ "id","firstName", "location","lastName","skills","positions","educations","languages","phone-numbers","certifications","emailAddress","mainAddress"])
  .result(function(profile) {
    displayProfiles(profile);
    IN.User.logout(); //After we take the data, we do a log out
    $.get("https://api.linkedin.com/uas/oauth/invalidateToken");
  });

Upvotes: 0

Related Questions