I start using GCM on a android device when i send data via CURL and PHP from my server to the GCM on my android app only get a null on the onMessageReceived i think that it was my code on the app but if i call the curl via terminal it shows the data hope you can help me with my php script to see what is wrong with this, by the way the in both i got the petition of GCM but only via terminal it displays the data
<?php
// Message to be sent
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'to' => 'ezgWcLrhacM:APA91bHzxeKdOnK.......gBfmpF3YrqOkjuHii296Ie1TPEmeQi-B-g_DJg0EHq89V0........7DCh3bzuHDOpN1Ksmp1n_EpkZvKrl56rrWB7M5Z8I',
'data ' => array( 'message' => 'Hello World!' ),
);
$headers = array(
'Content-Type: application/json',
'Authorization: key=AIzaSyBBgVZuc...........DnZeDY4OZr_uyI'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
//echo $ch;
//$info = curl_getinfo($ch);
// Execute post
echo json_encode($fields);
$result = curl_exec($ch);
// // Close connection
curl_close($ch);
echo $result;
?>
and the log from android terminal
05-07 06:34:48.694 14037-14239/mx.com.iubix.iubixmessage D/ListenerService: Datos recibidosBundle[{collapse_key=do_not_collapse}]
05-07 06:34:48.694 14037-14239/mx.com.iubix.iubixmessage D/ListenerService: From: 1007097169676
05-07 06:34:48.694 14037-14239/mx.com.iubix.iubixmessage D/ListenerService: Message: null
and where is the code i send from my terminal
curl --header "Authorization: key=AIzaSyBBgVZ........eDY4OZr_uyI" --header "Content-Typ.....e: application/json" https://android.googleapis.com/gcm/send -d "{\"to\":\"ezgWcLrhacM:APA91bHzxeKdOnKgk.......ZxjEchBezgBfmpF3YrqOkjuHii296Ie1TPEmeQi-B-g_DJg0EHq89V0yllLGw9Yji0zv.......Ksmp1n_EpkZvKrl56rrWB7M5Z8I\",\"data\":{\"message\":\"Hello World\"}}"
this one works fine