quinta-feira, 29 de julho de 2010

[JQUERY PHP] - Twitter com JSON e CURL

Atualmente está normal colocarmos o Twitter nos sites atuais. Fiz algumas pesquisas e testes e achei alguns scripts em PHP e Jquery que faz isso.

Exemplos com Jquery:

$(document).ready(function(){
      var tweeturl = "http://twitter.com/status/user_timeline/usertwitter.json?count=3&callback=?";
      $.getJSON(tweeturl,function(data){
            $.each(data, function(i, item) {
            $("#twitter ul").append("<li>" + item.text.link_r() + "</li> ");<br /> });<br /> });
            String.prototype.link_r = function() {
                  return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(aux) {
                  return aux.link(aux);
            });
      };
});




Outro exemplo:

$(function() {
      var html = "<ul>";
      var tweeturl = "http://twitter.com/status/user_timeline/usertwitter.json?count=3&callback=?";
      $.getJSON(tweeturl, function(d) {
            $.each(d, function(i, item) {
                  html += " <li>" + item.text + "</li> ";
            });
           html += "</ul>";
           $('#twitter-feed').append(html);
      });
});

Exemplo de PHP com CURL:
http://return-true.com/2010/02/connecting-to-twitter-api-using-php/

Outro exemplo com js:
http://snipplr.com/view/25197/twitter-json-url-hashtag--user-parser/

Download Jquery

Nenhum comentário:

Postar um comentário