Search code examples
javascriptjqueryjsontwittertumblr

How to get json data from javascript file


help, im using tumblr and connect my twitter account, Tumblr gave me this file example:http://titan-theme.tumblr.com/tweets.js

my question is can i get follower_count and screen_name data? if yes how to get it? please help me thanks


Solution

  • If you have only this file you should define *recent_tweets* function. Of cours you need to import tweets.js. For example:

    <script>
        var recent_tweets = function(tweets) {
            for(var i=0; i<tweets.length; i++) {
                var tweet = tweets[i];
                var followerCounts = tweet.user.followers_count;
                var screenName = tweet.user.screen_name;
            }
        }   
    </script>
    <script src="tweets.js"></script>
    

    However, there is no follower_count available.