LinkedIN Integration JS API - linkedin

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]
...........
}

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.

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");
});

Related

LinkedIn JavaScript SDK "You must specify a valid JavaScript API Domain as part of this key's configuration."

I want to show our LinkedIn company recent updates inside our web site. so i follow these steps, to integrate with LinkedIn JavaScript SDK # https://developer.linkedin.com/docs/getting-started-js-sdk . mainly i did the following steps:-
1- I created a new application .
2- then i add the following domains inside the "Valid SDK Domains". since the site i want to show the linkedin data inside it is a sharepoint online site which has the following url https://ourcompanyname.sharepoint.com :-
3- then inside my sharepoint page , i added the following script, to get the information from LinkedIn:-
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 0**********c
</script>
<script>
alert("1");
var liLogin = function() { // Setup an event listener to make an API call once auth is complete
IN.UI.Authorize().params({"scope":["r_basicprofile", "r_emailaddress"]}).place();
IN.Event.on(IN, 'auth', getProfileData);
}
var getProfileData = function() { // Use the API call wrapper to request the member's basic profile data
alert("2");
IN.API.Profile("me").fields("id,firstName,lastName,email-address,picture-urls::(original),public-profile-url,location:(name)").result(function (me) {
var profile = me.values[0];
var id = profile.id;
var firstName = profile.firstName;
var lastName = profile.lastName;
var emailAddress = profile.emailAddress;
var pictureUrl = profile.pictureUrls.values[0];
var profileUrl = profile.publicProfileUrl;
var country = profile.location.name;
alert(id);
});
}
</script>
<p>testing</p>
but on the browser i got the following error:-
Error: You must specify a valid JavaScript API Domain as part of this key's configuration. userspace:22:9
<anonymous>
https://www.linkedin.com/uas/js/userspace:22:9
<anonymous>
https://www.linkedin.com/uas/js/userspace:1:2
EDIT
Now based on #Lars Hendriks advice, i waited for 2 hours and i can see that the You must specify a valid JavaScript API Domain as part of this key's configuration. error is no longer showing inside my browser F12 console. but at the same time i can not see any data returned from the JavaScript call, even the alert("2") & alert(id) inside my above JavaScript did not get popup.. not sure what is going on ?
what you could try is :
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 0**********c
authorize: true
</script>
if this does not work , you might want to have to wait :
After registering an API key and specifying a valid domain, it may
take up to 30 minutes for the changes to take affect, so if it doesn't
work immediately, go grab a coffee and check back in a few.

Halt progress of Ninja Forms if Webhooks respond with error

I'm setting up Ninja Forms in Wordpress. And I want to use the Webhooks extension to post a code to an external URL. If the code is correct Ninja Forms should submit the data on move on. If the code is wrong then the user should get an error message and try again.
How can I do this, I see no way if interrupting the submit?
In Ninja Form when you use webhook, I guess you may catch the error respond from the API with this code
$data['errors']['form'][] = $this->submit_response->result[0]->error;
So when the API respond error, in this case user has no chance to re-submit the form again unless reload the page.
When the form contain the error, Ninja form prevent the form to submit, so you need to find a way to clear/remove this error.
Few workarounds can fix this problem.
An easy way is that, you cache the respond error differently with the following code:
$data['errors']['last']['message'] = $this->submit_response->result[0]->error;
With this code, your form will not display the error message respond from API but it is possible for user to re-submit the form again and you can use the javascript code below to display the error to some HTML element
var customFormController = Marionette.Object.extend({
initialize: function() {
// Listen to submit respond
this.listenTo(nfRadio.channel( 'forms' ), 'submit:response', this.checkSubmitRespond);
},
checkSubmitRespond: function(response, textStatus, jqXHR, formID) {
if ('undefined' != typeof response.errors.last) {
var msg = response.errors.last.message;
// display error on some pre-defined element
jQuery('.error-container').html(msg);
}
}
});
jQuery(document).ready(function($) {
new customFormController();
});
Hope this help.

Meteor: Resend email verification link

I want to be able to resend an email verification link to users of my Meteor application in case they accidentally delete their email verification email.
I have a link with the id "resentEmailVerificationLink"
I have the following code in my client for when the link is click (alerts are just there to show myself how far the function gets before an error):
Template.dashboard.events({
'click #resentEmailVerificationLink' : function(event) {
event.preventDefault();
var id = Meteor.userId();
alert('clicked: ' + id);
Accounts.sendVerificationEmail(id);
alert('Verification Email resent');
return false; // Stops page from reloading
}
)};
I know the sendVerificationEmail is a server function but I have no idea how to call this function in the server upon clicking the verify email link (I'm a bit of a Meteor newbie).
Any idea of how to accomplish this, because currently it doesn't work with the following error: Uncaught TypeError: Accounts.sendVerificationEmail is not a function
Note: Meteor.Accounts.sendVerificationEmail(id); doesn't work either (it does however produce a different error.
You can try with server side method just create one pass the attrs and call http://docs.meteor.com/#/full/accounts_sendverificationemail on the server. More about meteor methods: http://docs.meteor.com/#/full/meteor_methods

Meteor Streams : client doesn't receive streams

i'm working on a simple app based on meteor and MeteorStreams.
The aim is simple :
one user will click on a button to create a room
other users will join the room
those users can emit streams with simple message
the creator will listen to that message and then display them
In fact : message from other users are sent (log in server script), but the creator doesn't receive them.
If i reload the page of the creator, then it will get messages sent from other user.
I don't really understand why it doesn't work the first time.
I use meteor-router for my routing system.
Code can be seen here
https://github.com/Rebolon/MeetingTimeCost/tree/feature/pokerVoteProtection
for the client side code is availabel in client/views/poker/* and client/helpers
for the server stream's code is in server/pokerStreams.js
Application can be tested here : http://meetingtimecost.meteor.com
The creator must be logged.
If you have any idea, any help is welcome.
Thanks
Ok, Ok,
after doing some debugging, i now understand what is wrong in my code :
it's easy in fact. The problem comes from the fact that i forgot to bind the Stream.on event to Deps.autorun.
The result is that this part of code was not managed by reactivity so it was never re-run automatically when the Session changed.
The solution is so easy with Meteor : just wrap this part of code inside the Deps.autorun
Meteor.startup(function () {
Deps.autorun(function funcReloadStreamListeningOnNewRoom () {
PokerStream.on(Session.get('currentRoom') + ':currentRoom:vote', function (vote) {
var voteFound = 0;
// update is now allowed
if (Session.get('pokerVoteStatus') === 'voting') {
voteFound = Vote.find({subscriptionId: this.subscriptionId});
if (!voteFound.count()) {
Vote.insert({value: vote, userId: this.userId, subscriptionId: this.subscriptionId});
} else {
Vote.update({_id: voteFound._id}, {$set: {value: vote}});
}
}
});
});
});
So it was not a Meteor Streams problem, but only my fault.
Hope it will help people to understand that outside Template and Collection, you need to wrap your code inside Deps if you want reactivity.

JQuery AJAX Call reports success in every browser but Chrome

I'm working on a bit of legacy code that is being used to authenticate users to a web application via username/password check. The code is contained within a standard ASPX page (yes, I know) and, when the page is requested it either returns status 404 to indicate an authentication failure or populates a literal on the ASPX page if all is well.
Its a standard JQuery ajax call:
$("#btnSWSignInPin").click(function () {
$.ajax({
url: "/Security/Validate.aspx",
type: "GET",
data: "Rnd=" + Math.random() + "&Identifier=" + $(".inpIdentifier").val() + "&Pin=" + $("#inpSWPin").val(),
success: function () {
$("#divSessionLogin").jqmHide();
WarnInFuture();
DoChecks = true;
},
error: function () {
ShowLogin("The password you entered was incorrect. Please try again.");
}
});
$("#inpSWPin").val("");
return false;
});
The .NET code which this calls runs fine and I can successfully step through it with no issues in VS. I have tested extensively in Safari, Firefox and IE9, all but the latter on OSX and Windows, and it executes as expected. However in Chrome (latest build) the success function is never executed, the javascript seems to think that something other than status 200 is being returned from the browser although Fiddler shows its definitely a 200 in the Response header.
Can anyone suggest what I can check to try to understand and correct this behaviour?
I think it can be a url parsing problem, please try by giving your parameters this way :
data = {
"key_1": "value_1",
"key_2": false,
"key_4": 123
};
Set
async: false
Google Chrome seems to have an issue with firing success when async is set to true.

Resources