Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/01/2011, 06:28
_WILCO_
 
Fecha de Ingreso: marzo-2005
Mensajes: 26
Antigüedad: 19 años, 1 mes
Puntos: 0
Pregunta Ticker twitter para web, problema tildes

Qué tal.

Estoy intentando implementar un div en nuestra web que destaque los últimos mensajes de twitter.

He encontrado este código que funciona muy bien:

Código Javascript:
Ver original
  1. <html>
  2.  
  3.     <head>
  4.  
  5. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
  6.  
  7. <script type="text/javascript">
  8. jQuery(function($) {
  9.     var tweets = {
  10.         el: '.twitterTicker .twitter-stream',
  11.         items: new Array(),
  12.         count: 0,
  13.         total: -1,
  14.         delay: 6000,
  15.         animate: true
  16.     };
  17.     $(tweets.el+' p').each(function(i) {
  18.         tweets.items[i] = $(this).html();
  19.         tweets.total++;
  20.     }).hide();
  21.     runTweeter();
  22.     function runTweeter() {
  23.         if(tweets.animate == true) {
  24.             if($(tweets.el+' p').length > 0) {
  25.                 $(tweets.el).children('p').fadeOut(500, function() {
  26.                     $(this).parent(0).empty().append('<p style="display: none;">'+tweets.items[tweets.count]+'</p>').children('p').fadeIn(500);
  27.                 });
  28.             } else {
  29.                 $(tweets.el).empty().append('<p style="display: none;">'+tweets.items[tweets.count]+'</p>').children('p').fadeIn(750);
  30.             }
  31.         } else {
  32.             $(tweets.el).empty().append('<p>'+tweets.items[tweets.count]+'</p>');
  33.         }
  34.         setTimeout(function() {
  35.             if(tweets.count == tweets.total) {
  36.                 tweets.count = 0;
  37.             } else {
  38.                 tweets.count++;
  39.             }
  40.             runTweeter();
  41.         }, tweets.delay);
  42.     }
  43. });
  44. </script>
  45.  
  46.         <style type = "text/css">
  47.  
  48.             .twitter-stream {
  49.             background: #d5e8ef;
  50.             border: 1px solid #d5e8ef;
  51.             -moz-border-radius: 7px;
  52.             -webkit-border-radius: 7px;
  53.             -khtml-border-radius: 7px;
  54.             border-radius: 7px;
  55.             padding: 10px;
  56.             margin: 0 0 20px 0;
  57.             font-size: 10px;
  58.             color: #6e6f73;
  59.             font-weight: bold;
  60.             font-family: verdana;
  61.             float: left;
  62.             width: 87%;
  63.         }
  64.         .twitter-stream p {
  65.             padding: 0px;
  66.             margin: 0px;
  67.         }
  68.         .twitter-stream p a {
  69.             color: #45799f;
  70.             text-decoration: none;
  71.         }
  72.  
  73.         </style>
  74.  
  75.     </head>
  76.  
  77.     <body>
  78.  
  79.         <div class="twitterTicker"><img src="http://return-true.com/wp-content/themes/returntrue/images/layout/twittertickerbird.jpg" style="float:left;" />
  80.  
  81.                 <?php
  82.                         $doc = new DOMDocument();
  83.  
  84.                         # load the RSS -- replace 'username' with your own twitter username
  85.                         if($doc->load('http://twitter.com/statuses/user_timeline/USERNAME.rss')) {
  86.                           echo "<div class='twitter-stream'>";
  87.  
  88.                           # number of <li> elements to display.  20 is the maximum
  89.                           $max_tweets = 10;  
  90.  
  91.                           $i = 1;
  92.                           foreach ($doc->getElementsByTagName('item') as $node) {
  93.                             # fetch the title from the RSS feed.
  94.                             # Note: 'pubDate' and 'link' are also useful (I use them in the sidebar of this blog)
  95.                             $tweet = $node->getElementsByTagName('title')->item(0)->nodeValue;
  96.  
  97.                             # the title of each tweet starts with "username: " which I want to remove
  98.                             $tweet = substr($tweet, stripos($tweet, ':') + 1);  
  99.  
  100.                             # OPTIONAL: turn URLs into links
  101.                             $tweet = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@',
  102.                                   '<a href="$1">$1</a>', $tweet);
  103.  
  104.                             # OPTIONAL: turn @replies into links
  105.                             $tweet = preg_replace("/@([0-9a-zA-Z]+)/",
  106.                                   "<a href=\"http://twitter.com/$1\">@$1</a>",
  107.                                   $tweet);
  108.  
  109.                             echo "<p>". $tweet  . "</p>";
  110.  
  111.                             if($i++ >= $max_tweets) break;
  112.                           }
  113.                           echo "</div>";
  114.                         }
  115.  
  116.                         ?>
  117.     </body>
  118.  
  119. </html>

Aportado por AP Design en http://return-true.com/2010/09/building-a-twitter-ticker-with-jquery/

El problema es que no me respeta ñ, diéresis ni tildes como podéis ver en mi ejemplo:
http://www.forpe.es/ej_twitter-paul.php

No tengo conocimientos de javascript, por lo que si me pueden decir cómo solucionarlo se lo agradezco sumamente.

Gracias de antemano.