Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pusher PHP Auth example
$key = 'APP_KEY';
$secret = 'APP_SECRET';
$app_id = 'APP_ID';
$pusher = new Pusher($key, $secret, $app_id);
$channel_name = $_POST['channel_name'];
if(!$channel_name) {
$channel_name = $_GET['channel_name'];
$socket_id = $_POST['socket_id'];
if(!$socket_id) {
$socket_id = $_GET['socket_id'];
$callback = $_POST['callback'];
if(!$callback) {
$callback = $_GET['callback'];
if(!$channel_name) {
exit("channel_name must be supplied");
if(!$socket_id) {
exit("socket_id must be supplied");
//echo("channel_name: " . $channel_name . " socket_id: " . $socket_id);
$auth = $pusher->socket_auth($channel_name, $socket_id);
if(!$callback) {
header('Content-Type: application/json');
else {
$callback = str_replace('\\', '', $callback);
header('Content-Type: text/javascript');

This comment has been minimized.

Copy link

kufupatel commented Jun 15, 2012

I am trying to implement pusher notification service, currently i am using public channel so notification is accessible to all..
Can you give me brief info on how can use private channel so notification can go to only particular person on my website..
and which thing I have to consider to identify unique person so notification goes to only him ???
I am new to socket programming so I have no more knowledge on this ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.