Foros del Web » Programando para Internet » PHP »

Problema con Facebook (me gusta) y PHP

Estas en el tema de Problema con Facebook (me gusta) y PHP en el foro de PHP en Foros del Web. Hola, he probado el código tanto en PHP <iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];?>&layout=button_count&show_faces=false&width=80& action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:22px" allowTransparency="true"></iframe> como Javascript <SCRIPT LANGUAGE="JavaScript"> document.write("<iframe ...
  #1 (permalink)  
Antiguo 13/04/2011, 10:19
 
Fecha de Ingreso: abril-2011
Mensajes: 1
Antigüedad: 13 años
Puntos: 0
Pregunta Problema con Facebook (me gusta) y PHP

Hola,

he probado el código tanto en PHP

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];?>&layout=button_count&show_faces=false&width=80& action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:22px" allowTransparency="true"></iframe>

como Javascript

<SCRIPT LANGUAGE="JavaScript">
document.write("<iframe src=\"http:\/\/www.facebook.com\/plugins\/like.php?href="+document.URL+"&layout=button_count &show_faces=false&width=80&action=like&font=verdan a&colorscheme=light\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:80px; height:22px\" allowTransparency=\"true\"><\/iframe>");
</SCRIPT>

para añadir el botón “Me gusta” en páginas dinámicas, pero no me consigue obtener toda la URL completa (uso varias variables -obtenidas con PHP y Mysql- en la URL y se corta después de la primera) un ejemplo:

URL original: http://www.dominio.es/pagina.php?var1=24&var2=599&var3=1

y después de pinchar en el botón “me gusta” sólo enlaza a: http://www.dominio.es/pagina.php?var1=24

¿alguna sugerencia para poder solucionar esto?
  #2 (permalink)  
Antiguo 14/06/2011, 07:08
 
Fecha de Ingreso: mayo-2005
Mensajes: 10
Antigüedad: 18 años, 11 meses
Puntos: 1
Respuesta: Problema con Facebook (me gusta) y PHP

derrepente esto te ayude...
con php obtiene la url de tu pagina y solo te falta colocarlo en href del iframe......espero q te ayude suerte!

<?php
function getPostURL() {
$postURL = 'http://';

if ($_SERVER["SERVER_PORT"] != "80") {
$postURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$postURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $postURL;
}
$postURL=getPostURL();

echo '<iframe src="http://www.facebook.com/widgets/like.php?href='.$postURL.'"
scrolling="no" frameborder="0"
style="border:none; width:450px; height:40px"></iframe>';
?>

Etiquetas: botón, dinamicas, facebook, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:09.