var PubNub = require("pubnub");
var pubnub = new PubNub({
channel: 'Channel-xxxxxxxx',
publishKey : "pub-c-b91315c1-e6a1-xxxx-xxxx-xxxxxxxxxxxx",
subscribeKey : "sub-c-b4735f6a-b6f6-xxxx-xxxx-xxxxxxxxxxxx" });
pubnub.subscribe({
channel: 'Channel-xxxxxxxx',
callback: function(message) {
console.log("Message received: ", message);
},
error: function (err) {
console.log(err);
} });
使用pubnub文档上给出的示例代码仍然无法使其工作,不知道我哪里出错了
答案 0 :(得分:0)
试试这个:
var PubNub = require("pubnub");
var pubnub = new PubNub({
channel: 'Channel-xxxxxxxx',
publishKey : "pub-c-b91315c1-e6a1-xxxx-xxxx-xxxxxxxxxxxx",
subscribeKey : "sub-c-b4735f6a-b6f6-xxxx-xxxx-xxxxxxxxxxxx" });
pubnub.subscribe({
channel: 'Channel-xxxxxxxx',
callback: function(message) {
console.log("Message received: ", message);
},
error: function (err) {
console.log(err);
},
connect: publish
});