用于c2dm的Android 401
我使用相同的gmail id获得了用于c2dm的Android 401,android,Android,我使用相同的gmail id获得了注册id和authoCode,但我仍然获得了“未经授权”。我现在不知道怎么回事 同时注册Android云到设备消息。如果我正在使用abc@gmail.com,我用的是同样的abc@gmail.com在 Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER"); registrationIntent.putExtra("app", PendingIntent.
注册id
和authoCode
,但我仍然获得了“未经授权”。我现在不知道怎么回事
同时注册Android云到设备消息。如果我正在使用abc@gmail.com,我用的是同样的abc@gmail.com在
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
registrationIntent.putExtra("sender", "abc@gmail.com");
this.startService(registrationIntent);
获取authCode时的相同
https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&Email=abc@gmail.com&Passwd=XXXXX&source=XXXXXXX-0.1&service=cl
我使用的代码是
$headers = array('Authorization: GoogleLogin auth=' . $authCode);
$data = array(
'registration_id' => $registrationId,
'collapse_key' => "test",
'data.message' => "wass up" //TODO Add more params with just simple data instead
);
print_r($headers);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://android.apis.google.com/c2dm/send");
if ($headers)
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
echo($response);
return $response;
以下是我遵循的步骤
我是否遗漏了任何步骤?好的,这对我来说很糟糕 代码是好的,但我问了错误的服务认证代码 对于所有像我这样只是复制/粘贴示例的ppl 对于c2dm 在谷歌文档中,他们给出了谷歌日历服务=cl的例子 希望这对任何人都有帮助