Get Twitter Feed as JSON without authentication

前端 未结 8 569
难免孤独
难免孤独 2021-01-30 18:16

I wrote a small JavaScript a couple of years ago that grabbed a users (mine) most recent tweet and then parsed it out for display including links, date etc.

It used this

8条回答
  •  梦毁少年i
    2021-01-30 18:47

    The method "GET statuses/user_timeline" need a user Authentification like you can see on the official documentation :

    You can use the search method "GET search" wich not require authentification.

    You have a code for starting here : http://jsfiddle.net/73L4c/6/

    function searchTwitter(query) {
        $.ajax({
            url: 'http://search.twitter.com/search.json?' + jQuery.param(query),
            dataType: 'jsonp',
            success: function(data) {
                var tweets = $('#tweets');
                tweets.html('');
                for (res in data['results']) {
                    tweets.append('
    ' + data['results'][res]['from_user'] + ' wrote:

    ' + data['results'][res]['text'] + '


    '); } } }); } $(document).ready(function() { $('#submit').click(function() { var params = { q: $('#query').val(), rpp: 5 }; // alert(jQuery.param(params)); searchTwitter(params); }); })

提交回复
热议问题