linkedin and onLinkedInLoad - javascript

I have the possibility of LinkedIn login to my website, to postulate for a job. . I followed the tutorial given on the LinkedIn developer page, this is my code:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [...]
lang: fr_FR
authorize: false
onLoad: onLinkedInLoad
</script>
<script type="text/javascript">
// Setup an event listener to make an API call once auth is complete
function onLinkedInLoad() {
IN.Event.on(IN, "auth", getProfileData);
}
// Handle the successful return from the API call
function onSuccess(data) {
console.log(data);
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
function getProfileData(){
[...]
}
</script>
The login button appears, this means that LinkedIn was able to connect to my API key correctly, but the Chrome console gives me the following error: Uncaught Error: Could not execute 'onLinkedInLoad'. Please provide a valid function for callback..
I tried to remove the onLinkedInLoad event listener :
<script type="text/javascript">
IN.Event.on(IN, "auth", getProfileData);
[...]
</script>
... but i have the same problem.
Theses scripts are called in head (php include of all pages of the website (i need this linkedin login on all pages)).
It works on ONE page, but not on the others... i don't understand.
Thanks a lot !

Need to below script available for all pages where you want login button. if you are putting this script on particular page then lgoin button will work on that page only.
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: [...]
lang: fr_FR
authorize: false
onLoad: onLinkedInLoad
</script>

Related

Frame initialization failed

<html>
<head>
<meta name="google-signin-client_id" content="Myvalue.apps.googleusercontent.com">
</head>
<body>
<div id="my-signin2"></div>
<script>
function onSuccess(googleUser) {
console.log('Logged in as: ' + googleUser.getBasicProfile().getName());
}
function onFailure(error) {
console.log(error);
}
function renderButton() {
gapi.signin2.render('my-signin2', {
'scope': 'profile email',
'width': 240,
'height': 50,
'longtitle': true,
'theme': 'dark',
'onsuccess': onSuccess,
'onfailure': onFailure
});
}
</script>
<script src="https://apis.google.com/js/platform.js?onload=renderButton" async defer></script>
</body>
</html>
I tited to sign in using google but get these errors
cb=gapi.loaded_0?le=scs:177 Uncaught
{error: 'idpiframe_initialization_failed', details: 'You have created a new client application that use…i/web/guides/gis-migration) for more information.'}
details
:
"You have created a new client application that uses libraries for user authentication or authorization that will soon be deprecated. New clients must use the new libraries instead; existing clients must also migrate before these libraries are deprecated. See the Migration Guide for more information."
error
:
"idpiframe_initialization_failed"
Authentication and authorization with Google signin changed in HTML and JavaScript.
In this authentication-only sign-in scenario, example code and renderings of the existing Google Sign-In button are shown. Select from either Popup or Redirect mode to see differences in how the authentication response is handled either by a JavaScript callback or by secure redirect to your back-end server login endpoint.
The old way and deprecated.
<html>
<body>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<meta name="google-signin-client_id" content="YOUR_CLIENT_ID">
<div class="g-signin2" data-onsuccess="handleCredentialResponse"></div>
</body>
</html>
The new way
To use the new library in a simple authentication-only sign-in scenario select from either the Popup or Redirect mode and use the code sample to replace your existing implementation on your login page.
So what is the popup way:
Use a callback to handle sign-in directly from the user's browser.
<html>
<body>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload"
data-client_id="YOUR_CLIENT_ID"
data-callback="handleCredentialResponse">
</div>
<div class="g_id_signin" data-type="standard"></div>
</body>
</html>
And the redirect way is:
Google invokes your login endpoint as specified by the data-login_url attribute. Previously, you were responsible for the POST operation and parameter name. The new library posts the ID token to your endpoint in the credential parameter. Lastly, verify the ID token on your back-end server.
<html>
<body>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload"
data-client_id="YOUR_CLIENT_ID"
data-ux_mode="redirect"
data-login_uri="https://www.example.com/your_login_endpoint">
</div>
<div class="g_id_signin" data-type="standard"></div>
</body>
</html>

How to get posts from facebook page using javascript or php

I want post from my facebook page, can anyone please tell me the steps to do it? I see the solutions in web but can't getting what to do, can anyone help me to do this? I just have this code.
<html>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<body>
<p>Log In with the JavaScript SDK</p>
<script>
logInWithFacebook = function() {
FB.login(function(response) {
if (response.authResponse) {
alert('You are logged in & cookie set!');
// Now you can redirect the user or do an AJAX request to
// a PHP script that grabs the signed request from the cookie.
} else {
alert('User cancelled login or did not fully authorize.');
}
});
return false;
};
window.fbAsyncInit = function() {
FB.init({
appId: 'my-app-key',
cookie: true, // This is important, it's not enabled by default
version: 'v2.2'
});
};
</script>
</body>
</html>
In your application you have inserted wrong domain details. Check your settings.
Select the correct App and click in the edit button;
Check the URLs & paths are correctly entered and are pointing to the site where you have installed Ultimate Facebook plugin.

signin with Linkedin code give me html validation error

I'm using https://validator.w3.org to validate my HTML 5 website. I'm using Linkedin javascript login SDK. I followed this tutorial https://developer.linkedin.com/docs/signin-with-linkedin
I got this error
The text content of element script was not in the required format: Expected space, tab, newline, or slash but found a instead.
in this code block
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: YOUR_API_KEY_HERE
authorize: true
onLoad: onLinkedInLoad
</script>
The problem that this code is provided by the tutorial.
I solved this problem by separating the loading of the API and the initiation of the API.
<script src="http://platform.linkedin.com/in.js?async=true"></script>
<script>
IN.init({
api_key: 'YOUR_API_KEY_HERE',
onLoad: onLinkedInLoad,
authorize: true,
scope: 'r_basicprofile r_fullprofile r_emailaddress r_contactinfo',
});
</script>
this code is valid code by W3C

How to use a jquery HEAD request to obtain just metadata (response headers)

So, I've just read online about a fairly specialized HTTP method known as HEAD, which is basically supposed to only send metadata, without sending the actual document body. It seems that jQuery supports this, but when I attempted to create it for real, the body was still sent along with the headers. When I checked in the console, Chrome told me that a head request was actually sent. Huh?
Here's the code:
<!DOCTYPE html>
<html>
<head>
<meta charset = 'UTF-8'/>
<title>Headers</title>
</head>
<body>
<script language="Javascript" type="text/javascript"
src="2-jquery-1.11.0.min.js"></script>
<script language="Javascript" type="text/javascript"
src="jquery-ui-1.10.4.custom.min.js"></script>
<script language="Javascript" type="text/javascript">
$(function() {
$.ajaxSetup({ cache: false }); // not exactly necessary for head requests
// to be used for other ajax request types
//..is this interfering?
function reloader() {
$.ajax({ type: 'HEAD', url: "chatbox.txt" })
.done(function(data, status, xmlhttp) {
console.log(xmlhttp.getResponseHeader('Last-Modified')); })
.fail(function() { alert("error!"); })
.always( function() {} ); } // end reloader
var matrix = setInterval(reloader,3000);
$('#stop').click(function() { clearInterval(matrix); alert('stopped!');
}); // end click
}); // end $(document).ready()
</script>
<button id = 'stop'>Stop</button>
</body>
</html>
Everything works fine, except for the body being sent as well. What's the problem exactly? Am I accidentally sending the body along with the request? If so, where in the code is this?
P.S. I know I can do this with PHP, but I'm interested in js/jQ.
Thanks!

LinkedIn Login button is not displaying

I am trying to access linkedIn from my website. For that I have created a new Application and get the API key. And implemented in my code below. This gives me the blank page but works only in Javascript API developer console.
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: mykey
authorize: true
</script>
</head>
<body>
<script type="In/Login">
Hello, <?js= firstName ?> <?js= lastName ?>
</script>
</body>
Please help to get the login button..
The code looks alright as far as I can tell. As mentioned in the docs:
Verify that your API key, is specified in the framework script tag.
Verify that the full domain name you are using to access the html
file is specified in the key's configuration details.
Check your JavaScript Console for any framework errors.
If you are using Firebug or WebKit's Developer Tools, check to make
sure that the following files were loaded automatically: in.js,
userspace.js and framework.js
I found that you need a specific jQuery version to make the button appear!
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5b1.js"></script>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: xxxxxxxxxxxxx
onLoad: onLinkedInLoad
authorize: true
</script>
And to show the Button you will need also this somewhere BUT INSIDE A BODY TAG!!!
<body>
<script type="IN/Login"></script>
</body>
hope that will give some light to the issue!

Categories

Resources