javascript - How can I get Tweet Timeline with using Backbone.js? -


i'm beginner backbone.js. i've finished tutorials.

i want create non-tutorial app myself , try create simple app display tweet timeline using backbone collection or model.

here code. (oauth.js , sha1.js included in html)

$(function(){  var tweet = backbone.model.extend({ });  var twitter = backbone.collection.extend({     model: tweet,     initialize: function(api){         this.consumerkey = //consumerkey;         this.consumersecret = //consumersecret;         this.accesstoken = //accesstoken;         this.accesstokensecret = //accesstokensecret;          this.message = {             method: "get",             action: api,             parameters: {                 oauth_version: "1.0",                 oauth_signature_method: "hmac-sha1",                 oauth_consumer_key: this.consumerkey,                 oauth_token: this.accesstoken             }         };     },      gettimeline: function(){         var accessor = {             consumersecret: this.consumersecret,             tokensecret: this.accesstokensecret         };          oauth.settimestampandnonce(this.message);         oauth.signaturemethod.sign(this.message, accessor);         this.url =  oauth.addtourl(this.message.action, this.message.parameters);         var options = {             success: function(data, res){                 console.log(data);                 console.log(res);             }         };         this.fetch(options);     },      sync: function(method, model, options){         options.timeout = 10000;         options.datatype = 'jsonp';         return backbone.sync(method, model, options);     }  });  var twitter = new twitter("https://api.twitter.com/1.1/statuses/home_timeline.json"); twitter.gettimeline(); }); 

when refreshed html page 401 authorized massage displayed in console of chrome developer tool. timeline without backbone.js.

please teach me how should fix it.

thank kindness.

if work without backbone.js, use fetch method without backbone. anyways sync method full if rest, getting, updating, creating , deleting methods.

in case there fetch right? override fetch function , whatever done before pluging backbone in. listen own success , collection.reset.

var collection = backbone.collection.extend({    _onloaded : function(data) {        this.reset(data, {parse:true});    },    fetch : function() {        $.get("").success(_.bind(this._onloaded, this));    } }); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -