Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Created July 17, 2013 18:15
Show Gist options
  • Select an option

  • Save ToeJamson/6023015 to your computer and use it in GitHub Desktop.

Select an option

Save ToeJamson/6023015 to your computer and use it in GitHub Desktop.
PHP Push API Walkthrough
PUBNUB.subscribe( { channel : 'my_test_channel' },
function(message) {
if ('some_text' in message) {
alert(message.some_text);
}
} );
PUBNUB.publish({
channel : 'extra_cool_channel',
message : { 'some_var' : 'what up?' }
});
## Publish Messages To a JavaScript Browser
$pubnub = new Pubnub( 'publish_key', 'subscribe_key' );
$pubnub->publish(array(
'channel' => 'my_test_channel',
'message' => array( 'some_text' => 'hello!' )
));
$pubnub->subscribe(array(
'channel' => 'extra_cool_channel',
'callback' => function($message) {
var_dump($message);
return true; ## continue listening
}
));
array(1) {
["some_var"]=>
string(8) "what up?"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment