0
Wie kann ich die LinkedIn-Schaltfläche anmelden? Der Standard-LinkedIn-Button ist klein. Ich habe die Codes in here versucht, aber ich konnte es nicht zum Funktionieren bringen.Customize LinkedIn Anmelden Schaltfläche
Mein Code:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: #my key
onLoad: onLinkedInLoad
</script>
Der Button:
<script type="in/Login">
</script>
Das Skript:
// 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) {
var linkedInData = JSON.stringify(data);
logIn(linkedInData)
}
// Handle an error response from the API call
function onError(error) {
console.log(error);
}
// Use the API call wrapper to request the member's basic profile data
function getProfileData() {
IN.API.Raw("/people/~").result(onSuccess).error(onError);
}
function logIn(data){
$.ajax({
type: "POST",
url: URL_POST_AJAX,
data: {
'data' : data,
},
success: function (response) {
window.location.href = response.next_page;
},
error: function (data) {
alert('failed');
}
});}
// CSRF code
function getCookie(name) {
var cookieValue = null;
var i = 0;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (i; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
function csrfSafeMethod(method) {
// these HTTP methods do not require CSRF protection
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
crossDomain: false, // obviates need for sameOrigin test
beforeSend: function (xhr, settings) {
if (!csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
In der Frage, die Sie verknüpft, jemanden, der es während der 'onLinkedInLoad' Funktion modifiziert. Hast du das probiert? Veröffentlichen Sie den Code, den Sie ausprobiert haben. –
Sie meinen das? Ich versuchte dies, aber die Schaltfläche wurde nicht angezeigt. –
Ich habe es geschafft, danke Angel Politis! –