socializr
Advanced tools
Comparing version 0.2.26 to 0.2.27
@@ -97,2 +97,7 @@ var stream = require('stream') | ||
Facebook.prototype.unstream = function(request, auth, socializr){ | ||
return this; | ||
}; | ||
Facebook.prototype.auth = function(auth){ | ||
@@ -99,0 +104,0 @@ auth._provider = this; |
@@ -218,2 +218,7 @@ var stream = require('stream') | ||
GooglePlus.prototype.unstream = function(request, auth, socializr){ | ||
// this.request('https://www.googleapis.com/plus/v1/activities','GET',request); | ||
return this; | ||
}; | ||
module.exports = GooglePlus; |
@@ -66,2 +66,14 @@ var stream = require('stream') | ||
this.subscribe( data, function(err,res){ | ||
console.log('++++++++ instagram',res.body); | ||
}); | ||
} | ||
return this; | ||
}; | ||
Instagram.prototype.unstream = function(request, auth, socializr){ | ||
var data; | ||
this._tags = this._tags.concat( request.tags); | ||
for( var i in request.tags){ | ||
this.unsubscribe( request.tags[i].toString().replace('#',''), function(err,res){ | ||
console.log('++++++++ instagram',res.headers); | ||
@@ -125,8 +137,51 @@ }); | ||
Instagram.prototype.unsubscribe = function(type){ | ||
this._apiRequest( 'subscriptions', 'DELETE', { | ||
switch(type){ | ||
case 'all': | ||
case 'tag': | ||
case 'location': | ||
case 'user': | ||
case 'geography': | ||
this._apiRequest( 'subscriptions', 'DELETE', { | ||
client_id: this.clientId, | ||
client_secret: this.clientSecret, | ||
object: type | ||
}, function(){ | ||
console.log('unsubscribe instagram', type, arguments) | ||
}); | ||
break; | ||
default: | ||
var self = this; | ||
this.subscriptions( function(err,res){ | ||
data = res.body.data.data | ||
type = type instanceof Array ? type : [type]; | ||
console.log('unsubscribing tags', type); | ||
for(var i in data) { | ||
d = data[ i]; | ||
if( type.indexOf(d.object_id)){ | ||
self._apiRequest( 'subscriptions', 'DELETE', { | ||
client_id: self.clientId, | ||
client_secret: self.clientSecret, | ||
object: d.id | ||
}, function(err,res){ | ||
console.log('unsubscribe instagram', type[i], res.body) | ||
}); | ||
} | ||
}; | ||
}); | ||
break; | ||
} | ||
}; | ||
Instagram.prototype.subscriptions = function(cb){ | ||
this._apiRequest( 'subscriptions', 'GET', { | ||
client_id: this.clientId, | ||
client_secret: this.clientSecret, | ||
object: type | ||
}, function(){ | ||
client_secret: this.clientSecret | ||
}, function(err,data){ | ||
cb&&cb(err,data); | ||
}); | ||
@@ -133,0 +188,0 @@ }; |
@@ -637,3 +637,36 @@ /*! | ||
TwitterStream.prototype.removeData = function(data){ | ||
if( data.hasOwnProperty('tags')){ | ||
if( data.tags instanceof Array ){ | ||
for( var tag in data.tags){ | ||
this.removeTag( data.tags[tag]); | ||
} | ||
}else { | ||
this.removeTag( data.tags); | ||
} | ||
} | ||
if( data.hasOwnProperty('users')){ | ||
if( data.users instanceof Array ){ | ||
for( var user in data.users){ | ||
this.removeUser( data.users[user]); | ||
} | ||
}else { | ||
this.removeUser( data.users); | ||
} | ||
} | ||
if( data.hasOwnProperty('locations')){ | ||
if( data.locations instanceof Array ){ | ||
for( var locations in data.locations){ | ||
this.removeLocation( data.locations[location]); | ||
} | ||
}else { | ||
this.removeLocation( data.locations); | ||
} | ||
} | ||
if( data.hasOwnProperty('language')){ | ||
this.language = data.language; | ||
} | ||
}; | ||
TwitterStream.prototype._calculateDataSignature = function(){ | ||
@@ -1031,2 +1064,15 @@ return new Buffer([ | ||
Twitter.prototype.unstream = function(request, auth, socializr){ | ||
auth = auth instanceof Array ? auth : [auth]; | ||
var i, strm, self = this; | ||
for( i in auth){ | ||
strm = this.getStreamForAuth(auth[ i]); | ||
if( strm){ | ||
strm.removeData( request); | ||
strm.open(); | ||
} | ||
} | ||
return this; | ||
}; | ||
/** | ||
@@ -1033,0 +1079,0 @@ * |
@@ -41,2 +41,10 @@ var https = require('https') | ||
Socializr.prototype.unstream = function(request, auths){ | ||
auths = auths instanceof Array ? auths : [auths]; | ||
var self = this; | ||
for (var i = auths.length - 1; i >= 0; i--) { | ||
auths[i]._provider.unstream( request, auths[i], this); | ||
}; | ||
}; | ||
Socializr.prototype._onError = function(err, conn){ | ||
@@ -43,0 +51,0 @@ this.emit('warning', err, conn); |
{ | ||
"name": "socializr", | ||
"version": "0.2.26", | ||
"version": "0.2.27", | ||
"description": "Read data streams from several social networks.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
53442
1912