Create a gist now

Instantly share code, notes, and snippets.

Embed
Pusher PHP Auth example
<?php
// https://github.com/squeeks/Pusher-PHP
require('squeeks-Pusher-PHP-0defb40/lib/Pusher.php');
$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');
echo($auth);
}
else {
$callback = str_replace('\\', '', $callback);
header('Content-Type: text/javascript');
echo("$callback($auth);");
}
?>
@kufupatel

This comment has been minimized.

Show comment
Hide comment
@kufupatel

kufupatel 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 ...

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