C2DM411.这是一个错误. POST请求需要Content-length标头PHP [英] C2DM 411. That’s an error. POST requests require a Content-length header PHP

查看:84
本文介绍了C2DM411.这是一个错误. POST请求需要Content-length标头PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Am正在处理使C2DM成为用户的推送通知.我已经能够从Google获取用户注册ID,身份验证令牌.但是,当我尝试发送邮件时,我从Google收到此错误411.那是一个错误.POST请求需要Content-length标头".

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; // Registration ID

$device_id = "1"; // Used in case there is multiple messages being sent

$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?

推荐答案

authCode,


deviceRegistrationId,
deviceRegistrationId,


msgType ,


这篇关于C2DM411.这是一个错误. POST请求需要Content-length标头PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆