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.
Hello,
When trying to grant permission for a channel, I always get this.
This is the request sent:
Array
(
[channel] => my_channel
[auth] => 9f1fad32b54cf388b5d915a5af3a14db
[r] => 1
[w] => 1
[ttl] => 5
[timestamp] => 1404392170
)
I get:
Array
(
[status] => 400
[message] => Invalid Timestamp
[service] => Access Manager
[error] => 1
)
The timestamp is just php's core time(), so I don't know what is pubnub api expecting?
Thank you!