Am working on a push notification that makes user of C2DM. I have been able to obtain the users registration id, authentication token from Google. But when i try to send the message i receive this error from google "411. That’s an error. POST requests require a Content-length header".
function sendMessageToPhone($authCode, $deviceRegistrationId, $msgType, $messageText) {
$reg_id = $deviceRegistrationId;
$device_id = "1";
$headers = array('Authorization: GoogleLogin auth=' . $_SESSION['google'],'Content- Length: 818');
$data = array('registration_id' => $reg_id, 'collapse_key' => 'ck_' . $device_id, 'data.arg' => $message);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://android.apis.google.com/c2dm/send");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
echo "Reponse is ".$response;
}
how do i resolve this?