Página 2 de 2 PrimeroPrimero 12
Mostrando resultados del 11 al 16 de 16

Tema: Mostrar el numero de seguidores de Twitter en Wordpress

  1. #11
    Avatar de danielmd
    danielmd está desconectado Usuario Eta
    Registro
    06-abril-2009
    Ubicación
    Mexicali Beach
    Mensajes
    1.417
    CMS
    CMS Utilizado
    Ir a danielmd página de inicio Mi Twitter
    Acabo de buscar este código y creo que lo haz puesto incompleto, no lo he probado, pero funciona así tal cual lo ha publicado?
    Código completo
    Código PHP:
    function string_getInsertedString($long_string,$short_string,$is_html=false){
      if(
    $short_string>=strlen($long_string))return false;
      
    $insertion_length=strlen($long_string)-strlen($short_string);
      for(
    $i=0;$i<strlen($short_string);++$i){
        if(
    $long_string[$i]!=$short_string[$i])break;
      }
      
    $inserted_string=substr($long_string,$i,$insertion_length);
      if(
    $is_html && $inserted_string[$insertion_length-1]=='<'){
        
    $inserted_string='<'.substr($inserted_string,0,$insertion_length-1);
      }
      return 
    $inserted_string;
    }

    function 
    DOMElement_getOuterHTML($document,$element){
      
    $html=$document->saveHTML();
      
    $element->parentNode->removeChild($element);
      
    $html2=$document->saveHTML();
      return 
    string_getInsertedString($html,$html2,true);
    }

    function 
    getFollowers($username){
      
    $x file_get_contents("http://twitter.com/".$username);
      
    $doc = new DomDocument;
      @
    $doc->loadHTML($x);
      
    $ele $doc->getElementById('follower_count');
      
    $innerHTML=preg_replace('/^<[^>]*>(.*)<[^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele));
      return 
    $innerHTML;

    Fuente: Display the total number of your Twitter followers on your WordPress blog

    Por cierto, el que si probe ha sido este con javascript, tan solo cambian su username
    Código PHP:
    <script type="text/javascript" language="javascript" src="http://twittercounter.com/widget/index.php?username=danielmd"></script> 
    Siguemesta...
    Twitter: @danielmd

  2. #12
    Avatar de GnDx
    GnDx está desconectado Usuario Iota
    Registro
    06-abril-2009
    Ubicación
    MX
    Edad
    24
    Mensajes
    2.433
    CMS
    CMS Utilizado
    Ir a GnDx página de inicio Mi Twitter Mi Facebook
    muy bueno hoy lo implemento!!

    gracias
    @GnDx  | GnDx -

  3. #13
    Avatar de Herrerix
    Herrerix está desconectado Usuario Eta
    Registro
    29-junio-2009
    Ubicación
    Temuco, Chile
    Mensajes
    1.307
    CMS
    CMS Utilizado
    Buen aporte !!

  4. #14
    Avatar de D4rk_Dr4k0
    D4rk_Dr4k0 está desconectado Usuario Gamma
    Registro
    25-julio-2009
    Edad
    19
    Mensajes
    271
    en cualquier caso el que sea correcto para implementarlo en php sería algo asi:

    Crear twitterfollow.php con el siguiente codigo:

    Código PHP:
    function string_getInsertedString($long_string,$short_string,$is_html=false){
      if(
    $short_string>=strlen($long_string))return false;
      
    $insertion_length=strlen($long_string)-strlen($short_string);
      for(
    $i=0;$i<strlen($short_string);++$i){
        if(
    $long_string[$i]!=$short_string[$i])break;
      }
      
    $inserted_string=substr($long_string,$i,$insertion_length);
      if(
    $is_html && $inserted_string[$insertion_length-1]=='<'){
        
    $inserted_string='<'.substr($inserted_string,0,$insertion_length-1);
      }
      return 
    $inserted_string;
    }

    function 
    DOMElement_getOuterHTML($document,$element){
      
    $html=$document->saveHTML();
      
    $element->parentNode->removeChild($element);
      
    $html2=$document->saveHTML();
      return 
    string_getInsertedString($html,$html2,true);
    }

    function 
    getFollowers($username){
      
    $x file_get_contents("http://twitter.com/".$username);
      
    $doc = new DomDocument;
      @
    $doc->loadHTML($x);
      
    $ele $doc->getElementById('follower_count');
      
    $innerHTML=preg_replace('/^<[^>]*>(.*)<[^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele));
      return 
    $innerHTML;

    En la pag que lo quieras hacer hacer un include junto con el code:

    Ejemplo en alguna parte del index.php:

    Código PHP:
    <?php
    include ('twitterfollow.php');
    //Sustituir el "cuisi" por tu usuario de twitter y el texto seguido de el por lo que quieras que aparezca despues del numero de followers
    echo getFollowers("cuisi")." followers"
    ?>
    En teoría debería funcionar si no se me escapa algo xD estoy más oxidado en php de lo que pensaba

  5. #15
    Avatar de Plaga
    Plaga esta en línea ahora Moderador
    Registro
    15-abril-2009
    Ubicación
    Toluca y Valle de Bravo, México
    Edad
    23
    Mensajes
    6.505
    CMS
    CMS Utilizado
    Mi Twitter Mi Facebook Mi Google+
    Excelente aporte gracias!

    Cita Iniciado por sKr` Ver Mensaje
    buf muchas gracias !

    te iba a preguntar, en SMF hay un modulo que los aportes que hagas se postean automaticamente en twitter. Sabes algo para hacer esto en wordpress?

    Saludos!
    Con WordPress › Twitter Tools WordPress Plugins es el que yo uso
    Aquí no hay sentimientos, se trata de dinero y negocios!

    Antes de enviar un MP, reporta el mensaje: Reportar en lugar de enviar MPs

  6. #16
    Avatar de Luis Morales
    Luis Morales está desconectado Curioso
    Registro
    21-junio-2010
    Ubicación
    Japon, Japon
    Edad
    17
    Mensajes
    1.183
    CMS
    CMS Utilizado
    Ir a Luis Morales página de inicio Mi Twitter Mi Facebook
    Cita Iniciado por D4rk_Dr4k0 Ver Mensaje
    en cualquier caso el que sea correcto para implementarlo en php sería algo asi:

    Crear twitterfollow.php con el siguiente codigo:

    Código PHP:
    function string_getInsertedString($long_string,$short_string,$is_html=false){
      if(
    $short_string>=strlen($long_string))return false;
      
    $insertion_length=strlen($long_string)-strlen($short_string);
      for(
    $i=0;$i<strlen($short_string);++$i){
        if(
    $long_string[$i]!=$short_string[$i])break;
      }
      
    $inserted_string=substr($long_string,$i,$insertion_length);
      if(
    $is_html && $inserted_string[$insertion_length-1]=='<'){
        
    $inserted_string='<'.substr($inserted_string,0,$insertion_length-1);
      }
      return 
    $inserted_string;
    }

    function 
    DOMElement_getOuterHTML($document,$element){
      
    $html=$document->saveHTML();
      
    $element->parentNode->removeChild($element);
      
    $html2=$document->saveHTML();
      return 
    string_getInsertedString($html,$html2,true);
    }

    function 
    getFollowers($username){
      
    $x file_get_contents("http://twitter.com/".$username);
      
    $doc = new DomDocument;
      @
    $doc->loadHTML($x);
      
    $ele $doc->getElementById('follower_count');
      
    $innerHTML=preg_replace('/^<[^>]*>(.*)<[^>]*>$/',"\\1",DOMElement_getOuterHTML($doc,$ele));
      return 
    $innerHTML;

    En la pag que lo quieras hacer hacer un include junto con el code:

    Ejemplo en alguna parte del index.php:

    Código PHP:
    <?php
    include ('twitterfollow.php');
    //Sustituir el "cuisi" por tu usuario de twitter y el texto seguido de el por lo que quieras que aparezca despues del numero de followers
    echo getFollowers("cuisi")." followers"
    ?>
    En teoría debería funcionar si no se me escapa algo xD estoy más oxidado en php de lo que pensaba
    mUy buenoo lo implementare en mi blog

    Vendo theme de GenMX (Por MP). Venta de Enlaces (Oferta) -------------> Blogger Invitado en GenMX (Iniciativa Dominios Gratis).

Página 2 de 2 PrimeroPrimero 12

Información del tema

Users Browsing this Thread

Actualmente hay 1 usuarios leyendo este tema. (0 miembros y 1 invitados)

Temas Similares

  1. Como evitar mostrar la palabra category y tag en las urls de Wordpress
    Por Ignatius en el foro Optimización de buscadores
    Respuestas: 12
    Último mensaje: 16-jun-2011, 05:31
  2. cambiar número de post mostrados
    Por alejandrogm en el foro Wordpress
    Respuestas: 7
    Último mensaje: 19-feb-2010, 05:14
  3. Un plugin para poner el numero de pagina
    Por kachi en el foro Wordpress
    Respuestas: 12
    Último mensaje: 02-ago-2009, 17:12
  4. Mostrar adsense debajo de los titulos
    Por Facundo en el foro Blogger
    Respuestas: 8
    Último mensaje: 10-jun-2009, 17:13
  5. Mostrar numero de comentarios en la entrada
    Por Facundo en el foro Wordpress
    Respuestas: 6
    Último mensaje: 06-jun-2009, 19:55

Normas de Publicación

  • No puedes crear nuevos temas
  • No puedes responder mensajes
  • No puedes subir archivos adjuntos
  • No puedes editar tus mensajes
  •