Deprecated. Please use https://github.com/pubnub/php
###YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API. ###http://www.pubnub.com/account
www.pubnub.com - PubNub Real-time Push Service in the Cloud. http://www.pubnub.com/blog/php-push-api-walkthrough
$pubnub = new Pubnub(
"demo", ## PUBLISH_KEY
"demo", ## SUBSCRIBE_KEY
"", ## SECRET_KEY
false ## SSL_ON?
);
$info = $pubnub->publish(array(
'channel' => 'hello_world', ## REQUIRED Channel to Send
'message' => 'Hey World!' ## REQUIRED Message String/Array
));
print_r($info);
$messages = $pubnub->history(array(
'channel' => 'hello_world', ## REQUIRED Channel to Send
'limit' => 100 ## OPTIONAL Limit Number of Messages
));
print_r($messages); ## Prints array of messages.
$timestamp = $pubnub->time();
var_dump($timestamp); ## Prints integer timestamp.
$pubnub->subscribe(array(
'channel' => 'hello_world', ## REQUIRED Channel to Listen
'callback' => create_function( ## REQUIRED PHP 5.2.0 Method
'$message',
'var_dump($message); return true;'
)
));
$pubnub->subscribe(array(
'channel' => 'hello_world', ## REQUIRED Channel to Listen
'callback' => function($message) { ## REQUIRED Callback With Response
var_dump($message); ## Print Message
return true; ## Keep listening (return false to stop)
}
));
$pubnub->presence(array(
'channel' => $channel,
'callback' => function($message) {
print_r($message);
echo "\r\n";
return true;
}
));
$here_now = $pubnub->here_now(array(
'channel' => $channel
));
$history = $pubnub->detailedHistory(array(
'channel' => $channel,
'count' => 10,
'end' => "13466530169226760"
));