Comparing version 0.2.21 to 0.2.24
@@ -58,4 +58,8 @@ var stream = require('stream') | ||
function Facebook(opts){ | ||
function Facebook(options){ | ||
options = _.extend({ | ||
filters: [] | ||
},options); | ||
Transform.call(this, { | ||
@@ -65,9 +69,10 @@ objectMode: true | ||
this.appId = opts.appId; | ||
this.appSecret = opts.appSecret; | ||
this.appId = options.appId; | ||
this.appSecret = options.appSecret; | ||
this.appAccessToken = this.getApplicationToken(); | ||
this.subscriptionCallbackURL = opts.subscriptionCallbackURL; | ||
this.pubsub = opts.pubsub || new PubSubConnection( this.appSecret, this); | ||
this.subscriptionCallbackURL = options.subscriptionCallbackURL; | ||
this.pubsub = options.pubsub || new PubSubConnection( this.appSecret, this); | ||
this.uuid = uuid.v1(); | ||
this._filters = options.filters; | ||
this._tags = []; | ||
@@ -191,3 +196,3 @@ }; | ||
var expected = 0 | ||
, fb = this | ||
, stream = this | ||
; | ||
@@ -208,11 +213,15 @@ for( var i in chunk.entry){ | ||
console.log("post:",res.text, res.body); | ||
if( res.error){ | ||
console.log(res.error); | ||
}else { | ||
fb.push( | ||
new Message( this, JSON.parse(res.text) ) | ||
); | ||
}else{ | ||
var data = JSON.parse(res.text); | ||
console.log("post:",res.text, res.body); | ||
if( this.include(data)) { | ||
stream.push( | ||
new Message( this, data ) | ||
); | ||
} | ||
} | ||
@@ -232,3 +241,14 @@ | ||
Facebook.prototype.include = function(data){ | ||
var pass = true; | ||
this._filters.forEach( function(cb){ | ||
if( !cb(data)){ | ||
pass = false; | ||
return false; | ||
} | ||
}); | ||
return pass; | ||
}; | ||
Facebook.prototype._graphRequest = function(endpoint, method, data, cb){ | ||
@@ -235,0 +255,0 @@ |
@@ -25,2 +25,6 @@ var stream = require('stream') | ||
function GooglePlus(options){ | ||
options = _.extend({ | ||
filters: [] | ||
},options); | ||
Transform.call(this, { | ||
@@ -34,3 +38,4 @@ objectMode: true | ||
this._pageCount = 0; | ||
this._refreshRate = options.refresh || 15000 | ||
this._refreshRate = options.refresh || 15000; | ||
this._filters = options.filters; | ||
@@ -178,8 +183,8 @@ this.uuid = uuid.v1(); | ||
try { | ||
// console.log("++++"); | ||
// console.log(Message,JSON.parse(data) ); | ||
// console.log("----"); | ||
this.push( | ||
new Message( this, JSON.parse(data) ) | ||
); | ||
data = JSON.parse(data); | ||
if( this.include(data)){ | ||
this.push( | ||
new Message( this, data ) | ||
); | ||
} | ||
}catch(err){ | ||
@@ -193,2 +198,14 @@ console.log(err); | ||
GooglePlus.prototype.include = function(data){ | ||
var pass = true; | ||
this._filters.forEach( function(cb){ | ||
if( !cb(data)){ | ||
pass = false; | ||
return false; | ||
} | ||
}); | ||
return pass; | ||
}; | ||
GooglePlus.prototype.stream = function(request, auth, socializr){ | ||
@@ -195,0 +212,0 @@ if( !this._piped){ |
@@ -27,3 +27,7 @@ var stream = require('stream') | ||
function Instagram(opts){ | ||
function Instagram(options){ | ||
options = _.extend({ | ||
filters: [] | ||
},options); | ||
@@ -34,10 +38,11 @@ Transform.call(this, { | ||
this.clientId = opts.appId; | ||
this.clientSecret = opts.appSecret; | ||
this.subscriptionCallbackURL = opts.subscriptionCallbackURL; | ||
this.clientId = options.appId; | ||
this.clientSecret = options.appSecret; | ||
this.subscriptionCallbackURL = options.subscriptionCallbackURL; | ||
this.pubsub = opts.pubsub || new PubSubConnection( this.clientSecret, this); | ||
this.pubsub = options.pubsub || new PubSubConnection( this.clientSecret, this); | ||
this.uuid = uuid.v1(); | ||
this._tags = [] | ||
this._filters = options.filters; | ||
this._tags = []; | ||
}; | ||
@@ -63,3 +68,3 @@ util.inherits(Instagram, Transform); | ||
this.subscribe( data, function(err,res){ | ||
// console.log('++++++++ instagram',arguments); | ||
console.log('++++++++ instagram',res.headers); | ||
}); | ||
@@ -152,6 +157,8 @@ } | ||
stream.push( | ||
new Message(stream,data[j]) | ||
); | ||
// console.log( data[j]); | ||
if( this.include(data[j])){ | ||
stream.push( | ||
new Message(stream,data[j]) | ||
); | ||
} | ||
} | ||
@@ -171,2 +178,15 @@ complete(); | ||
Instagram.prototype.include = function(data){ | ||
var pass = true; | ||
this._filters.forEach( function(cb){ | ||
if( !cb(data)){ | ||
pass = false; | ||
return false; | ||
} | ||
}); | ||
return pass; | ||
}; | ||
Instagram.prototype.getMediaByTag = function(tag, cb){ | ||
@@ -173,0 +193,0 @@ this._apiRequest( 'tags/' + tag + '/media/recent', 'GET', { |
@@ -940,4 +940,8 @@ /*! | ||
*/ | ||
function Twitter(auth,options){ | ||
function Twitter(options){ | ||
options = _.extend({ | ||
filters: [] | ||
},options); | ||
Transform.call(this, { | ||
@@ -947,9 +951,11 @@ objectMode: true | ||
this._auth = auth; | ||
this._auth = { | ||
key: options.key, | ||
secret: options.secret | ||
}; | ||
this._streamByAuth = {}; | ||
this._filters = options.filters || []; | ||
this._filters = options.filters; | ||
this.uuid = uuid.v1(); | ||
console.log(this.uuid); | ||
}; | ||
@@ -956,0 +962,0 @@ util.inherits(Twitter, Transform); |
{ | ||
"name": "socializr", | ||
"version": "0.2.21", | ||
"version": "0.2.24", | ||
"description": "Read data streams from several social networks.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50306
1805