The community forums are in BETA and closed to the public.

PHP publish, Socket.io receive

I currently have the following in my PHP file, which returns a "Sent" response.

require_once __DIR__.'/autoloader.php';
$pubnub = new Pubnub\Pubnub("...", "...");
$publish_result = $pubnub->publish("mychannel", array(
"from" => "me",
"to" => "to",
"txt" => "Hello World"
));

This is my javascript/socket.io file.

var pubnub_setup = {
  channel       : 'mychannel',
  publish_key   : '...',
  subscribe_key : '...'
};

pubnub = io.connect('http://pubsub.pubnub.com', pubnub_setup);

pubnub.on('connect', function () {
  pubnub.on( 'message', function(xmsg) {
    console.log(xmsg);
  });

pubnub.send({
      from: "me",
      to: "you",
      txt: "Hello more worldz"
    });
});

My socket.io client does not appear to receive any messages from the php application, but it does receive messages if you load the web page in multiple tabs.

Any idea why I'm not receiving the messages from the php app..or anything other recommendations to help guide me along? I have been reading over the documentation, but have not found a solution yet.

I changed my php to this, and it works.

require_once __DIR__.'/autoloader.php';
$pubnub = new Pubnub\Pubnub("...", "...");
$publish_result = $pubnub->publish("mychannel", array( 
  "ns" => "standard-mychannel",
  "name" => "message",
  "data" => array(
    "from" => "me",
    "to" => "you",
    "txt" => "Hello World",
)));

Comments to this discussion are now closed!