Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 79 lines (70 sloc) 2.505 kB
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
1 ## ---------------------------------------------------
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored
2 ##
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
3 ## YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
f6f309e @stephenlb updated README link for each API.
stephenlb authored
4 ## http://www.pubnub.com/account
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
5 ##
6 ## ----------------------------------------------------
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored
7
8 ## -----------------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
9 ## PubNub 3.0 Real-time Cloud Push API - PHP
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored
10 ## -----------------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
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
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
36 var_dump($info);
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored
37
38 ## --------------------------
39 ## Request Messages (HISTORY)
40 ## --------------------------
b88ab19 @stephenlb updated PHP Client Library to PubNub PHP Push API 2.0 version.
stephenlb authored
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
44 ));
b88ab19 @stephenlb updated PHP Client Library to PubNub PHP Push API 2.0 version.
stephenlb authored
45 var_dump($messages); ## Prints array of messages.
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored
46
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
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
53 ## ----------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
54 ## PHP 5.2.0. THIS WILL BLOCK!!!
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored
55 ## Receive Message (SUBSCRIBE)
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
56 ## THIS WILL BLOCK. PHP 5.2.0
6d185a3 @stephenlb added README for php Client API directory.
stephenlb authored
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
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
64 ));
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored
65
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
66
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored
67 ## ----------------------------------
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
68 ## PHP 5.3.0 ONLY. THIS WILL BLOCK!!!
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored
69 ## Receive Message (SUBSCRIBE)
b893080 @stephenlb Upgraded to PubNub 3.0 PHP Real-time Cloud Push API.
stephenlb authored
70 ## THIS WILL BLOCK. PHP 5.3.0 ONLY!!!
09ee0a2 @stephenlb updated php README with version 5.2.0 subscribe example.
stephenlb authored
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
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
78 ));
Something went wrong with that request. Please try again.