Created
August 30, 2011 10:31
-
-
Save leggetter/1180618 to your computer and use it in GitHub Desktop.
Pusher PHP Auth example
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
<?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);"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ...