Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

simple ping in php

  • Loading branch information...
commit ab583d7bc5811f2f43bb4000b1525903a82cbec9 1 parent 9528364
geremy cohen authored
Showing with 51 additions and 0 deletions.
  1. +51 −0 php/3.4/ping.php
View
51 php/3.4/ping.php
@@ -0,0 +1,51 @@
+<?php
+require_once('Pubnub.php');
+
+// TODO: Add SSL version of these tests
+## ---------------------------------------------------------------------------
+## USAGE:
+## ---------------------------------------------------------------------------
+#
+# php ./pubnubPlaintextTests.php
+# php ./pubnubPlaintextTests.php [PUB-KEY] [SUB-KEY] [SECRET-KEY] [CIPHER-KEY] [USE SSL]
+#
+
+
+## Capture Publish and Subscribe Keys from Command Line
+$publish_key = isset($argv[1]) ? $argv[1] : 'demo';
+$subscribe_key = isset($argv[2]) ? $argv[2] : 'demo';
+$secret_key = isset($argv[3]) ? $argv[3] : false;
+$cipher_key = isset($argv[4]) ? $argv[4] : false;
+$ssl_on = false;
+
+## ---------------------------------------------------------------------------
+## Create Pubnub Object
+## ---------------------------------------------------------------------------
+$pubnub = new Pubnub( $publish_key, $subscribe_key, $secret_key, $cipher_key, $ssl_on );
+
+## ---------------------------------------------------------------------------
+## Define Messaging Channel
+## ---------------------------------------------------------------------------
+$channel = "a";
+
+## ---------------------------------------------------------------------------
+## Publish Example
+## ---------------------------------------------------------------------------
+echo "Running publish\r\n";
+
+while (1) {
+
+$t = time();
+
+$publish_success = $pubnub->publish(array(
+ 'channel' => $channel,
+ 'message' => $t + 'Hello from PHP!'
+));
+echo($t . " " . $publish_success[0] . " " . $publish_success[1]);
+echo "\r\n";
+
+sleep(1);
+}
+
+?>
+
Please sign in to comment.
Something went wrong with that request. Please try again.