以下是当前代码(订阅单个项目)
podio.authenticate('password', {
'username': podioUser.username,
'password': podioUser.password
}, function (response, body) {
const item_id = 1234567;
podio.get('/item/' + item_id, {}, function (response, body) {
push.addSubscription(body.push);
});
});
这是完整的代码,
// Initialize faye client
var fayeClient = new faye.Client('https://push.podio.com/faye');
// Extend faye client with signature and timestamp used for authentication
fayeClient.addExtension({
'outgoing': function (message, callback) {
message.ext = message.ext || {};
message.ext = {private_pub_signature: push.channel.signature, private_pub_timestamp: push.channel.timestamp};
callback(message);
}
});
const push = {
subscription: null,
channel: null,
addSubscription: function (channel) {
this.channel = channel;
this.subscription = fayeClient.subscribe(this.channel.channel).withChannel(function (channel, message) {
var client = new faye.Client('http://localhost:8000/');
client.publish('/messages', {
text: message
});
});
this.subscription.then(function () {
console.log('Subscription is now active');
}, function (error) {
console.error('Subscription failed: ', error.message, error);
});
}
};
podio.authenticate('password', {
'username': podioUser.username,
'password': podioUser.password
}, function (response, body) {
const item_id = 1234567;
podio.get('/item/' + item_id, {}, function (response, body) {
push.addSubscription(body.push);
});
});
bayeux.attach(server);
server.listen(8002);
是否可以订阅多个项目?我尝试了项目ID循环和订阅,它没有工作。