Skip to content Skip to sidebar Skip to footer

Pubnub Server Does Not Format Message Properly

I have the server configuration to speak to the Android clients as:

Solution 1:

Sending JSON over PubNub

Send the JSON object without stringifying it first. In the case for PHP, do not json_encode the message. PubNub SDK will encode and decode it for you.

This:

$post_data = array("type"=> "groupMessage", "data" => array(
    "chatUser" => "SERVER", "chatMsg" => "Now lets talk", 
    "chatTime"=>1446514201516));

Not this:

$post_data = json_encode(array("type"=> "groupMessage", "data" => array(
    "chatUser" => "SERVER", "chatMsg" => "Now lets talk", 
    "chatTime"=>1446514201516)));

Please comment if this resolves or not.

Post a Comment for "Pubnub Server Does Not Format Message Properly"