WARNING: This content is OLD!
Please visit https://github.com/pubnub/pubnub-api

PHP Push API

PHP API Calls for the Pubnub class. This provides a complete Publish + Subscribe Push Notifications Framework for PHP Developers. This class is pluggable in any framework such as Drupal and Symphony. Read the Blog on PHP Push API Walkthrough for a detailed walk-through of this reference.

Download PHP Push API on GitHub

Initialize

// new Pubnub(pub_key, sub_key)
$pubnub = new Pubnub( 'publish_key', 'subscribe_key' );

Get Your API Keys You need the Publish and Subscribe Keys. Ignore the Secret Key.

Publish

// pubnub->publish( options )
$pubnub->publish(array(
    'channel' => 'my_channel',
    'message' => array( 'my_var' => 'my text data' )
));

subscribe

// $pubnub->subscribe( options )
$pubnub->subscribe(array(
    'channel ' => 'my_channel',
    'callback' => function($message) {
        var_dump($message['my_var']); // print message
        return true;             // keep listening?
    }
));

Subscribe() function will *Block* as it waits for a new messages to be published.

history

// $pubnub->history( options )
$messages = $pubnub->history(array(
    'channel' => 'my_channel',
    'limit'   => 10
));

Nothing more complex is needed for real time message passing! For an in depth walk-through of the PHP Push API Framework, follow the Blog PHP Push API Walkthrough .

Ready To Get Started?

Contact Sales