Created
July 17, 2013 18:15
-
-
Save ToeJamson/6023015 to your computer and use it in GitHub Desktop.
PHP Push API Walkthrough
This file contains hidden or 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
| PUBNUB.subscribe( { channel : 'my_test_channel' }, | |
| function(message) { | |
| if ('some_text' in message) { | |
| alert(message.some_text); | |
| } | |
| } ); |
This file contains hidden or 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
| PUBNUB.publish({ | |
| channel : 'extra_cool_channel', | |
| message : { 'some_var' : 'what up?' } | |
| }); |
This file contains hidden or 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
| ## 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!' ) | |
| )); |
This file contains hidden or 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
| $pubnub->subscribe(array( | |
| 'channel' => 'extra_cool_channel', | |
| 'callback' => function($message) { | |
| var_dump($message); | |
| return true; ## continue listening | |
| } | |
| )); |
This file contains hidden or 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
| 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