Skip to content
Newer
Older
100644 79 lines (70 sloc) 2.45 KB
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 8, 2010
1 ## ---------------------------------------------------
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored Jun 4, 2010
2 ##
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
3 ## YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
f6f309e @stephenlb updated README link for each API.
stephenlb authored Mar 31, 2011
4 ## http://www.pubnub.com/account
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
5 ##
6 ## ----------------------------------------------------
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 4, 2010
7
8 ## -----------------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
9 ## PubNub 3.0 Real-time Cloud Push API - PHP
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
10 ## -----------------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
11 ##
12 ## www.pubnub.com - PubNub Real-time Push Service in the Cloud.
13 ## http://www.pubnub.com/blog/php-push-api-walkthrough
14 ##
15 ## PubNub is a Massively Scalable Real-time Service for Web and Mobile Games.
16 ## This is a cloud-based service for broadcasting Real-time messages
17 ## to thousands of web and mobile clients simultaneously.
18
19 ## ------------
20 ## PHP Push API
21 ## ------------
22 $pubnub = new Pubnub(
23 "demo", ## PUBLISH_KEY
24 "demo", ## SUBSCRIBE_KEY
25 "", ## SECRET_KEY
26 false ## SSL_ON?
27 );
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
28
29 ## ----------------------
30 ## Send Message (PUBLISH)
31 ## ----------------------
32 $info = $pubnub->publish(array(
33 'channel' => 'hello_world', ## REQUIRED Channel to Send
34 'message' => 'Hey World!' ## REQUIRED Message String/Array
35 ));
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
36 var_dump($info);
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
37
38 ## --------------------------
39 ## Request Messages (HISTORY)
40 ## --------------------------
b88ab19 @stephenlb updated PHP Client Library to PubNub PHP Push API 2.0 version.
stephenlb authored Jun 16, 2010
41 $messages = $pubnub->history(array(
42 'channel' => 'hello_world', ## REQUIRED Channel to Send
43 'limit' => 100 ## OPTIONAL Limit Number of Messages
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
44 ));
b88ab19 @stephenlb updated PHP Client Library to PubNub PHP Push API 2.0 version.
stephenlb authored Jun 17, 2010
45 var_dump($messages); ## Prints array of messages.
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
46
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
47 ## --------------------------
48 ## Request Server Time (TIME)
49 ## --------------------------
50 $timestamp = $pubnub->time();
51 var_dump($timestamp); ## Prints integer timestamp.
52
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
53 ## ----------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
54 ## PHP 5.2.0. THIS WILL BLOCK!!!
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
55 ## Receive Message (SUBSCRIBE)
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
56 ## THIS WILL BLOCK. PHP 5.2.0
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
57 ## ----------------------------------
58 $pubnub->subscribe(array(
59 'channel' => 'hello_world', ## REQUIRED Channel to Listen
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
60 'callback' => create_function( ## REQUIRED PHP 5.2.0 Method
61 '$message',
62 'var_dump($message); return true;'
63 )
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored Jun 5, 2010
64 ));
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored Jun 5, 2010
65
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
66
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored Jun 5, 2010
67 ## ----------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
68 ## PHP 5.3.0 ONLY. THIS WILL BLOCK!!!
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored Jun 5, 2010
69 ## Receive Message (SUBSCRIBE)
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
70 ## THIS WILL BLOCK. PHP 5.3.0 ONLY!!!
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored Jun 5, 2010
71 ## ----------------------------------
72 $pubnub->subscribe(array(
73 'channel' => 'hello_world', ## REQUIRED Channel to Listen
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored Nov 9, 2010
74 'callback' => function($message) { ## REQUIRED Callback With Response
75 var_dump($message); ## Print Message
76 return true; ## Keep listening (return false to stop)
77 }
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored Jun 5, 2010
78 ));
Something went wrong with that request. Please try again.