0

I'm trying to get some information out of my incomming messages from Google Cloud Message (GCM). Message looks like this:

{
    "category":"com.myappplication",
    "data": {
        "my_message":"this data i need",
        "my_action":"com.google.android.gcm.demo.app.ECHO_NOW"
        },
    "time_to_live"86400,
    "message_id":"5",
    "from":"ADJEKRJEKRJEKJREKRJLSDLKSJDLKJ23DSD22232320DSLKJ23"
}

I only can get the data out of the "from","message_id" and "time_to_live".

In my Php script I decode the incomming json message

    $gcm_in = json_decode(str_replace(""", "\"", $stanza_in->childrens[0]->text));

    $from = $gcm_in->from;

How to get the information of my_message?

Theo Jansen
  • 81
  • 1
  • 4
  • 11

1 Answers1

1

Considering the json data that you specified is stored in variable $data.

$objData = json_decode($data);
echo $objData->data->my_message;

json_decode function converts data fomr json format to php object.

Though I am not sure why tried to replace " in your code and originally in which variable you are receiving data.

Vivek Vaghela
  • 1,075
  • 9
  • 16