UPDATE - OFFICIAL PHP PAM SDK NOW HERE - https://github.com/pubnub/php
require('pam.php');
$manager = new access(
"pub-c-e132b7b4-0c2c-4d36-a828-1de1ea50d167",
"sub-c-f95db694-6ff9-11e3-9291-02ee2ddab7fe",
"sec-c-OWFkNWQ1NDctN2JiNy00NzJmLTk3Y2ItN2ExODZlYzkyNzY0"
);
Grant access to user with authkey
of gZW5jb2RlZCBmaWx
with read
and write
access for 5
minute ttl
.
print_r($manager->grant(
"my_channel", // CHANNEL
"gZW5jb2RlZCBmaWx", // STRING (AUTH KEY)
true, // READ
true, // WRITE
5 // TTL in MINUTES
));
Also grant access to the presence channel (required for PubNub Dev Console).
print_r($manager->grant(
"my_channel-pnpres", // CHANNEL
"gZW5jb2RlZCBmaWx", // STRING (AUTH KEY)
true, // READ
true, // WRITE
5 // TTL in MINUTES
));
Exclude the authkey
and you can global grant access to all.
print_r($manager->grant_global(
"my_channel", // CHANNEL
true, // READ
true, // WRITE
5 // TTL in MINUTES
));
You can grant access forever by setting the ttl
param to 0
.
print_r($manager->grant_global(
"my_channel", // CHANNEL
true, // READ
true, // WRITE
0 // FOREVER GRANT!!!
));
Instantly revoke access to a user.
print_r($manager->revoke(
"some-other-channel", // CHANNEL
"gZW5jb2RlZCBmaWx" // STRING (AUTH KEY)
));
You can also revoke Global Access by excluding the authkey
param.
print_r($manager->revoke(
"some-other-channel" // CHANNEL
));
WARNING: PubNub Dev Console Requires Grant on Presence Channel too! You can set the presence access by granting on the suffix of -pnpres
channel name.
Hi thank you for this repo, I have an angular app and I am trying to grant with php and then subscribe with angular. I get a response with the php script but when I try to subscribe with the token through angular I get 403s. Like maronin it works fine in the dev console.
I ajax post to my php script, on success init and subscribe in js. Any ideas?
Edit: Figured out that I was calling init again in the js and overwriting the first init, i have stopped the 403s.