Last active
August 29, 2015 14:01
-
-
Save pgl/28bb140dbb8802b6da70 to your computer and use it in GitHub Desktop.
Pubnub test script
This file contains 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
#!/usr/bin/php | |
<?php | |
/* | |
* CLI test script | |
* | |
* Call as: | |
* | |
* publishtest.php | |
* publishtest.php "uncompressed message" 0 | |
* publishtest.php "compression test" 1 # gzip compress msg when publishing | |
*/ | |
require_once './Pubnub.php'; | |
// $conf can easily be replaced with an ini file | |
// eg: $conf = parse_ini_file('pubnub.ini'); | |
$conf = [ | |
'pubnub.channel' => 'my_channel', | |
'pubnub.pub_key' => 'demo', | |
'pubnub.sub_key' => 'demo', | |
]; | |
$msg = $argv[1] ?: 'test'; | |
$compress = $argv[2] ?: false; | |
$pubnub = new Pubnub($conf['pubnub.pub_key'], $conf['pubnub.sub_key'], $compress); | |
if ($compress) { | |
echo "using compression\n"; | |
} | |
$return = $pubnub->publish([ | |
'channel' => $conf['pubnub.channel'], | |
'message' => [ 'test message' => $msg ], | |
'compress' => $compress, | |
]); | |
print_r($return); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One liner: