Cómo integrar este código de Facebook en una página web

  • Autor Autor Felipe
  • Fecha de inicio Fecha de inicio
Felipe

Felipe

Iota
Redactor
Verificación en dos pasos activada
Verificado por Whatsapp
Muchas gracias, alguien me podría indicar como usar este codigo de fuente en mi web, muchas gracias de ante mano! 🙂

Insertar CODE, HTML o PHP:
<script type="text/javascript" src="/script/lacopucha.fbapp.js?j=91570"></script>

Insertar CODE, HTML o PHP:
// Facebook 

function hideContent() {
    var h2_title = '<br><h2>Para ver contenido exclusivo de La Copucha y tener acceso a sus Comentarios Hazte Fan haciendo click en <strong>me gusta</strong> como ya lo han hecho tantos otros amigos</h2>';
    //var html_like = '<div class="fb-like" data-href="http://www.facebook.com/pages/LaCopucha/209628545756563" data-send="false" data-layout="box_count" data-width="80" data-show-faces="false" data-font="lucida grande"></div><br><br><br>';
    var html_like=$("#like-fb").html();
	//var html_like = '<fb:like send="false" layout="button_count" width="90" font="arial" action="like" href="http://www.facebook.com/lacopucha"></fb:like><br><br><br>';
	$('#lc-like').empty().html(h2_title + html_like); 
	

}

function postCopucha() {
		var token = FB.getAuthResponse()['accessToken'];
		var action = "lacopucha:gossip";
		FB.api('/me/lacopucha:gossip?article='+location.href,'post',
		function(response) {
			var msg = 'ha ocurrido un error';
			if (!response || response.error) {
				if (response.error) {
					msg += "\n\nType: "+response.error.type+"\n\nMessage: "+response.error.message;
				}
				/*console.log(msg);*/
             		}  else { 
    				_gaq.push(['_trackEvent','facebook','app','activo',1,true]);
			}
		});
};
function readCopucha() {
		var token = FB.getAuthResponse()['accessToken'];
		FB.api('/me/news.reads?article='+location.href,'post',
		function(response) {
			var msg = 'ha ocurrido un error';
			if (!response || response.error) {
				if (response.error) {
					msg += "\n\nType: "+response.error.type+"\n\nMessage: "+response.error.message;
				}
				/*console.log(msg);*/
             		}  else { 
    				//_gaq.push(['_trackEvent','facebook','app','activo',1,true]);
			}
		});
}

function getCookie(c_name) {
    var i,x,y,ARRcookies=document.cookie.split(";");
    for (i=0;i<ARRcookies.length;i++) {
        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
        x=x.replace(/^\s+|\s+$/g,"");
        if (x==c_name) {
            return unescape(y);
        }
    }
}

function generateUniqueId() {
    var Number = new Date().getTime();
    var Random = Math.random();
    var UniqueId = Number + "" + Random;
    UniqueId = UniqueId.replace(".", "");
    return UniqueId;
}

function getUniqueId() {
    var UniqueId = getCookie("LaCopuchaId");
    if(UniqueId === undefined) {
        UniqueId = generateUniqueId();
        setCookie("LaCopuchaId", UniqueId, 365)
    }
    return UniqueId;
}

function checkCookie() {
var lc_cookie=getCookie("copuchar");
//console.log(lc_cookie);
  if (lc_cookie!=null && lc_cookie==1) {
    // post /me/lacopucha:copuchar
    setTimeout("postCopucha()",11000);
  } else {
    if (lc_cookie==undefined) {
        setCookie("copuchar",1,14);
        //console.log(":)");
    }
  }
}

function checkCookie2() {
var lc_cookie=getCookie("copuchar");
//console.log(lc_cookie);
  if (lc_cookie!=null && lc_cookie==1) {
    // post /me/lacopucha:copuchar
    setTimeout("readCopucha()",11000);
  } else {
    if (lc_cookie==undefined) {
        setCookie("copuchar",1,14);
        //console.log(":)");
    }
  }
}

function setCookie(c_name,value,exdays) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value + "; path=/";
}

function setCopuchaSocial(v) {
    setCookie("copuchar",v,14);
}


function openDialog() {
    jQuery('.ui-dialog-titlebar').hide();
    jQuery('#permisos').dialog('open');
}

function isFanOtro(id,label){
    pageid = id;
    FB.api({ method: 'pages.isFan', 
           page_id: pageid },
           function(resp) {
			 if (resp) {
			     // Codigo de marcas SI ES FAN
			     _gaq.push(['_setCustomVar', 3, label, 'es fan', 2]);
			 } else {
			     _gaq.push(['_setCustomVar', 3, label, 'no es fan', 2]);
			 }
			
        });
    }
    
function isFanLC(){
    FB.api({ method: 'pages.isFan', 
           page_id: '209628545756563' }, 
           function(resp) {
			 if (resp) {
                jQuery('#lc-like').hide();
                jQuery('.lc-exclusive-div').show('blind');
                jQuery('#faceout').show('blind');
			 } else {
			     if(document.getElementById("lc-like")) { 
			       $('#faceout').hide();
			       hideContent();
                 }
			 }
        });
    }

function loginForm() {
    var h2_title = '<br><h2>Para ver este contenido exclusivo y tener acceso a sus Comentarios conéctate con La Copucha via Facebook como ya lo han hecho tantos otros amigos</h2>';
    var html_like = '<img onClick="fbLogin();" style="cursor:pointer;" class="fb-conn" src="/wp-content/themes/TheStyle/images/login_facebook.png" /><br><br><br>';
    $('#lc-like').empty().html(h2_title + html_like);
	if(document.getElementById("lc-like")) {
        $('#faceout').hide();
	}
}


function logUser(usuario,token) {
    $.post('/script/log.php',{
            fbuid: usuario.id,
            token: token,
            name: usuario.name,
            email: eml,
            sexo: usuario.gender
            });
}

function fbLogin() {
    FB.login(function(response) {
     if (response.authResponse) {
      FB.api('/me', function(response) {
    	_gaq.push(['_setCustomVar', 1, 'id', response.id, 2]);  //identificador único
    	_gaq.push(['_setCustomVar', 2, 'genero', response.gender, 2]);  //genero hombre o mujer
    	logUser(response);
     });
     isFanOtro('127708121003','fan_emol');
     isFanOtro('180581311952130','fan_jaidef'); 
     isFanLC();
   } else {
        loginForm(); 
   }
 },{scope:'offline_access,user_likes,email,publish_actions'});  //publish_stream
}

window.fbAsyncInit = function() {
	FB.init({
      appId      : '184228368307277',
      channelUrl : '//www.lacopucha.com/channel.html',
      status     : true,
      cookie     : true,
      xfbml      : true    
      });
    
    FB.Event.subscribe('edge.create', function(href, widget) {
        jQuery('#lc-like').hide('fold');
        jQuery('.lc-exclusive-div').show('blind');
        jQuery('#faceout').show('blind');
        _gaq.push(['_trackEvent', 'Facebook', 'Like', 'http://www.lacopucha.com/']);
    });
    
    var conso = console;
    
    FB.Event.subscribe('comment.create', function(response) {
        //alert("Gracias por tu comentario");
        //console.log("Gracias por tu comentario");
        //console.log(response);
        //_gaq.push(['_trackEvent', 'Facebook', 'Comment', location.href]);
    });
    
    FB.getLoginStatus(function(response) {
      viralIcons(FB.getAccessToken());
      if (response.status === 'connected') {
        var accessToken = response.authResponse.accessToken;
        if (response.session && (accessToken=='')) {	
          accesToken=response.session.access_token;
        }
        if (response.authResponse && (accessToken=='')) {
          accessToken=response.authResponse.accessToken;
        }
        FB.api('/me', function(response) {
          $('#social-switch-pic').attr('src','https://graph.facebook.com/'+response.id+'/picture');
          usr = response;
          eml = response.email;
          _gaq.push(['_setCustomVar', 1, 'id', response.id, 2]);  //identificador único
    	  _gaq.push(['_setCustomVar', 2, 'genero', response.gender, 2]);  //genero hombre o mujer
          logUser(response,accessToken,eml);
          isFanOtro('127708121003','fan_emol');
          isFanOtro('180581311952130','fan_jaidef');
          isFanLC();
        });
      } else if (response.status === 'not_authorized') {
        loginForm();
      } else {
        loginForm();
      }
    });   
};

(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/es_ES/all.js";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));

// end Facebook

var socialDefine = function(sw){
    if (sw==1) {
        alert('desactivando....');
        setCookie("copuchar",0,14);
        $('#social-button').attr('value',"Compartir Desactivado");
        $('#social-switch').addClass('social-switch-off');
        $('#social-switch').removeClass('social-switch-on');
    } else {
        alert('activando....');
        setCookie("copuchar",1,14);
        $('#social-button').attr('value',"Compartir Activado");
        $('#social-switch').addClass('social-switch-on');
        $('#social-switch').removeClass('social-switch-off');
    }
    sswitch = getCookie("copuchar");
}

var sswitch = 0;

jQuery(document).ready(function($) {
	
    $('#permisos').dialog({
        autoOpen:false,
        height:200,
        width:200,
		modal:true
    });
    
    $('#social-switch').mouseover(function(){
        $('#social-switch-over').fadeIn(250);
    });
    
    $('#social-switch').mouseout(function(){
        $('#social-switch-over').fadeOut(250);
    });
    
    $('#permisos .fb-conn').click(function(){
        fbLogin();
    });
    
    $('#permisos .cerrar').click(function(){
        $('#permisos').dialog('close');
        loginForm();
    });
    
    if (location.href!="http://www.lacopucha.com/" && location.href!="http://www.lacopucha.com/internacional/ashton-kutcher-y-su-cita-con-mila-kunis/") {
        checkCookie();
    }
    
    if (location.href=="http://www.lacopucha.com/internacional/ashton-kutcher-y-su-cita-con-mila-kunis/") {
        checkCookie2();
    }
    
    sswitch = getCookie("copuchar");
    if (sswitch==1) {
        $('#social-button').attr('value',"Compartir Activado");
        $('#social-switch').addClass('social-switch-on');
        $('#social-switch').removeClass('social-switch-off');
    } else {
        $('#social-button').attr('value',"Compartir Desactivado");
        $('#social-switch').addClass('social-switch-off');
        $('#social-switch').removeClass('social-switch-on');
    }
    
});
 
Última edición:
Bueno al aparecer es un script para desbloquear.. Hace contacto con el api de fb luego postea en muro guarda cookie para no volver a pedir permisos y ya.
Si me contactas por msn que esta en mi firma te paso sin coste un script js de "desbloquear" aunque ya hay varios en la red.
Saludos.
 
Bueno al aparecer es un script para desbloquear.. Hace contacto con el api de fb luego postea en muro guarda cookie para no volver a pedir permisos y ya.
Si me contactas por msn que esta en mi firma te paso sin coste un script js de "desbloquear" aunque ya hay varios en la red.
Saludos.

Muchas gracias Zentido, intentare hacerlo funcionar yo, si no lo logro, pues te contacto! 😉
Saludos y muchas gracias nuevamente.
 
De nada socio un gusto
Saludos :sorrow:
 
Atrás
Arriba