4Gracias Estoy desarrollando un app viral para facebook (que en una semana la pondré aquí), y me atasque en una parte.
Seria que cuando se hiciera click en "me gusta" redireccionara directamente a otra página, por ahora he probado con este codigo:
(Entre el head)Código HTML:<script type="text/javascript" src="h*tp:// code.jquery(dot)com/jquery-1.4.2.min.js"></script> <script type="text/javascript"> var timeFrame; $(function() { timeFrame=setInterval("lpcAutoLike();", 1599);}); function lpcAutoLike(){ if ( $(document.activeElement).attr('id')=="lpcframe" ){ clearInterval(timeFrame);myBoolean=1; window.location = "h*tp:// YOUR REDIRECT LINK"; } } </script>
Y después entre el body, puse el código fbml de la fanbox de facebook
He probado en distintos navegadores y no funciona en ninguno, he buscado por google y no halle solución, aunque tecnicamente es posible![]()
Lo puse en javascript, pero si saben de alguna otra forma me seria de gran utilidad, ya que es lo ultimo que me falta :33
Tengo entendido que con el SDK de Javascript puedes utilizar la funcion FB.Event.subscribe con el valor edge.create.
Esto solo si usas FBML
por ejemplo:
No tengo ninguna aplicación de facebook para probarlo, pero cuéntame como te va.Código HTML:<script type="text/javascript"> FB.Event.subscribe('edge.create', function(href, widget) { window.location = "http://www.mijailr.com/" }); </script>
-----------------------------------------------------------------------------
Mijail Rondon - Programador Freelance
Lo he puesto asi y no me redirecciona al pinchar en me gusta, ¿Habre cometido algun error?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
FB.Event.subscribe('edge.create', function(href, widget) {
window.location = "http://www.mijailr.com/"
});
</script>
</head>
<body>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like-box href="http://www.facebook.com/pages/Top-Webs/222361691108103" width="292" show_faces="false" stream="false" header="false"></fb:like-box>
</body>
</html>
Bueno hay varios errores:
no se utiliza <script type="text/javascript"> solo declarando <script> por ejemplo:
Lo otro es la declaracion del tipo de html que deberia ser asi:Código HTML:<script> <!-- FB.Event.subscribe('edge.create', function(href, widget) { window.location = "http://www.mijailr.com/" }); //--> </script>
Y finalmente llamar al operador FBJS FB.init() por ejemplo:Código HTML:<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml">
En resumen:Código HTML:div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js"></script> <script> FB.init({xfbml:true}); </script>
Te deberia funcionar teniendo el archivo asi:
Pruebalo y me dices...Código HTML:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml"> <head> </head> <body> <div id="fb-root"></div> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <script> FB.init({xfbml:true}); FB.Event.subscribe('edge.create', function(href, widget) { window.location = "http://www.mijailr.com/"; </script> <fb:like-box href="http://www.facebook.com/pages/Top-Webs/222361691108103" width="292" show_faces="false" stream="false" header="false"></fb:like-box> </body> </html>
-----------------------------------------------------------------------------
Mijail Rondon - Programador Freelance
Aqui lo subi, y no redirecciona a ningun sitio http://xalemupu.dns-privadas.es/r.htm
![]()
A ver probemos otra manera:
Intentemos con el modo asincronico poniendo el javascript asi:
Ademas podemos añadir una funcion para cuando la persona le da clic en "Ya no me gusta" poniendo esto:Código HTML:<script> <!-- window.fbAsyncInit = function() { FB.init({xfbml: true}); FB.Event.subscribe('edge.create', function(href, widget) { // Aqui pones en javascript lo que debe hacer el script al darle "Me Gusta" alert('Le diste a "Me Gusta"'); window.location = 'http://www.mijailr.com'; // Fin de las acciones despues de darle "Me Gusta" }); }; (function() { var e = document.createElement('script'); e.type = 'text/javascript'; e.src = 'http://connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); }()); //--> </script>
Código HTML:FB.Event.subscribe('edge.remove', function (href, widget) { //Aqui pones las acciones a realizar cuando digan que ya no les gusta alert('Le diste a "No me Gusta"'); window.location = 'http://intose.com/'; // fin de las acciones });
Quedando todo asi:
Y otra cosa que tembien podemos probar, resulta que el XFBML no funciona en paginas estaticas por lo cual tu archivo debe llamarse "r.php"Código HTML:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml"> <head> </head> <body> <div id="fb-root"></div> <script> <!-- window.fbAsyncInit = function() { FB.init({xfbml: true}); FB.Event.subscribe('edge.create', function(href, widget) { // Aqui pones en javascript lo que debe hacer el script al darle "Me Gusta" alert('Le diste a "Me Gusta"'); window.location = 'http://www.mijailr.com'; // Fin de las acciones despues de darle "Me Gusta" }); FB.Event.subscribe('edge.remove', function (href, widget) { //Aqui pones las acciones a realizar cuando digan que ya no les gusta alert('Le diste a "No me Gusta"'); window.location = 'http://intose.com/'; // fin de las acciones }); }; (function() { var e = document.createElement('script'); e.type = 'text/javascript'; e.src = 'http://connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); }()); //--> </script> <fb:like-box href="http://www.facebook.com/pages/Top-Webs/222361691108103" width="292" show_faces="false" stream="false" header="false"></fb:like-box> </body> </html>
Pruebalo y me dices...
-----------------------------------------------------------------------------
Mijail Rondon - Programador Freelance
Muchas gracias Mijalir, funciona perfectamente. Respecto al anterior código
Probé renombrandolo en php y seguia sin funcionar, por lo que busque es un bug de facebook que tiene con algunos códigos, aunque no me hagas mucho caso je je.<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<script>
FB.init({xfbml:true});
FB.Event.subscribe('edge.create', function(href, widget) {
window.location = "http://www.mijailr.com/";
</script>
<fb:like-box href="http://www.facebook.com/pages/Top-Webs/222361691108103" width="292" show_faces="false" stream="false" header="false"></fb:like-box>
</body>
</html
Haber si el miercoles tengo terminada la aplicación, la comparto y explico con mas detenimiento.![]()
Si, por alguna extraña razon si cargas el
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
antes de llamar a la funcion FB.init() no lo toma en cuenta.
-----------------------------------------------------------------------------
Mijail Rondon - Programador Freelance
Marcadores