Last active
October 1, 2015 00:01
-
-
Save girliemac/2de6b803e0ec00aba448 to your computer and use it in GitHub Desktop.
PubNub Access Manager Getting Started Guide Code samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://cdn.pubnub.com/pubnub-[version number].js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdn.pubnub.com/pubnub-crypto.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pubnub = require('pubnub').init({ | |
subscribe_key: 'sub-c-f762fb78-...', | |
publish_key: 'pub-c-156a6d5f-...', | |
secret_key: 'sec-c-M2U0N...' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pubnub = PUBNUB.init({ | |
subscribe_key: 'sub-c-f762fb78-...', | |
publish_key: 'pub-c-156a6d5f-...', | |
auth_key: 'my_auth_key_from_login' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pubnub = PUBNUB.init({ | |
subscribe_key: 'sub-c-f762fb78-...', | |
publish_key: 'pub-c-156a6d5f-...', | |
auth_key: 'my_auth_key_from_login' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.auth('my_new_auth_key'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.grant({ | |
read: true, | |
write: true, | |
ttl: 60, | |
callback: function(m){console.log(m)}, | |
error: function(m){console.error(m)} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.grant({ | |
channel: 'public-room', | |
read: true, | |
write: true, | |
callback: function(m){console.log(m)} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.grant({ | |
channel: 'private-83659357', | |
auth_key: 'abcxyz123-auth-key', | |
read: true, | |
write: true, | |
ttl: 60, | |
callback: function(m){console.log(m)} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var channel = 'auth-chat'; | |
pubnub.grant({ | |
channel: channel, | |
auth_key: '9ae4c23e1a8c6654efddf98c2b8ab5fba3f...', // OAuth token | |
read: true, | |
write: true, | |
callback: function(m){console.log(m)} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
send.addEventListener('click', function(e) { | |
pubnub.publish({ | |
channel : channel, | |
message : {text: input.value} | |
}); | |
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
["PUBLISH ERROR",{"message":"Forbidden","payload":{"channels":["my-chat"]}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.revoke({...}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.grant({ | |
read: false, | |
write: false, | |
... | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.revoke({ | |
channel : channel, | |
auth_key : '9ae4c23e1a8c6654efddf98c2b8ab5fba3f...' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.audit({callback : function(m){console.log(m)}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.audit ({ | |
channel: channel, | |
auth_key: '9ae4c23e1a8c6654efddf98c2b8ab5fba3f...', | |
callback : function(m){console.log(m)} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.audit({ | |
callback: function(m){ | |
console.log(util.inspect(m, false, null)); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ channels: | |
{ channel': | |
{ auths: | |
{ '94e4cc3e1-user-auth': { r: 1, m: 0, w: 0, ttl: 1440 }, | |
'619f8945a4f-admin-auth': { r: 1, m: 0, w: 1, ttl: 1440 } } }, | |
'my-chat-pnpres': | |
{ auths: { '619f8945a4f-admin-auth': { r: 1, m: 0, w: 0, ttl: 1440 } } } }, | |
subscribe_key: 'sub-c-981...', | |
objects: {}, | |
'channel-groups': {}, | |
level: 'subkey' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubnub.grant({ | |
channel: channel+'-pnpres', | |
auth_key: '9ae4c23e1a8c6654efddf98c2b8ab5fba3f...', | |
read: true, | |
write: false, | |
callback: function(m){console.log(m);} , | |
error: function(err){console.log(err);} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment