Comparing version 0.0.17 to 0.0.18
@@ -19,10 +19,34 @@ var stream = require('stream') | ||
function Page(id, accessToken){ | ||
this.id = id; | ||
function OAuthConnection(accessToken, ownerId){ | ||
this.accessToken = accessToken; | ||
this.tokenOwner = ownerId; | ||
}; | ||
function OAuthConnectionStore() { | ||
_connections = {}; | ||
}; | ||
OAuthConnectionStore.prototype.add = function(accessToken, ownerId){ | ||
return new OAuthConnection( accessToken, ownerId); | ||
}; | ||
OAuthConnectionStore.prototype.get = function(ownerId){ | ||
return this._connections.hasOwnProperty(ownerId) ? | ||
this._connections[ ownerId] : | ||
null; | ||
}; | ||
OAuthConnectionStore.prototype.drop = function(ownerId){ | ||
if( this._connections.hasOwnProperty(ownerId) ){ | ||
delete this._connections[ ownerId]; | ||
return true; | ||
} | ||
return false; | ||
}; | ||
function PubSubConnection(secret){ | ||
@@ -59,2 +83,4 @@ this.appSecret = secret; | ||
this._pubsubConnections = {}; | ||
this._oauthConnections = new OAuthConnectionStore(); | ||
}; | ||
@@ -130,2 +156,3 @@ util.inherits(Facebook, Transform); | ||
Facebook.prototype.install = function(pageId, token, cb){ | ||
this._oauthConnections.add( token, pageId); | ||
this._graphRequest( pageId + '/tabs', 'POST', { | ||
@@ -178,7 +205,10 @@ app_id: this.appId, | ||
var expected = 0 | ||
, fb = this; | ||
, fb = this | ||
; | ||
for( var i in chunk.entry){ | ||
//console.log(chunk.entry[i].changes); | ||
console.log(chunk.entry[i].changes); | ||
var auth = this._oauthConnections.get( chunk.entry[i].id); | ||
for( var j in chunk.entry[i].changes){ | ||
@@ -191,2 +221,3 @@ | ||
this._graphRequest( chunk.entry[i].changes[j].value.post_id, 'GET', { | ||
access_token: auth.accessToken | ||
}, function(res){ | ||
@@ -193,0 +224,0 @@ expected--; |
{ | ||
"name": "socializr", | ||
"version": "0.0.17", | ||
"version": "0.0.18", | ||
"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
30812
1162