weibo-js
v0.1.0
Published
Matador compliant library for weibo.com api
Downloads
3
Readme
weibo.js
Matador compliant weib.com API SDK, supporting oAuth flow and general API calls
Usage
npm install -g matador
matador init matador-app
cd matador-app
npm install matador weibo-js
app.use(matador.session({secret: 'key'}))
app.use(require('weibo-js').middleware({
appId : 'appId',
secret : 'appSecret',
loginUrl: '/auth/login',
logoutUrl: '/auth/logout',
callbackUrl: '/auth/callback'
}))
module.exports = require('matador').BaseController.extend(function() {
this.viewFolder = '';
this.addBeforeFilter(this.requireAuth)
}).methods({
requireAuth : function(callback) {
if(this.request.weibo)
return callback(null)
this.response.redirect('/auth/login?redirect=' + this.request.url);
}
})
module.exports = require(app.set('controllers') + '/ApplicationController').extend(function() {
this.addExcludeFilter(['index'], this.requireAuth)
}).methods({
index : function() {
this.render('index', {
title : 'The Matador Framework'
})
},
status : function() {
var that = this;
this.request.weibo.get('/statuses/friends_timeline.json', function(status) {
that.json(status);
}, function(error) {
console.log(error);
that.render('500');
});
}
})