0
我得到了registration_id
和authoCode
使用相同的Gmail的身份证,但我仍然得到“未经授权”。现在我无能为力了。Android 401 for c2dm
在注册Android Cloud到设备消息传递时。如果我使用[email protected],我使用同样的[email protected]在
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
registrationIntent.putExtra("sender", "[email protected]");
this.startService(registrationIntent);
同为同时获得AUTHCODE
https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&[email protected]&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;
这些步骤我跟着
- 我创建了一个新的GOOGL我的应用程序
- é帐户http://code.google.com/android/c2dm/signup.html
- 首先注册它运行的应用程序在模拟器上获得注册ID
- 使用相同的Gmail ID来获得AUTHCODE
- 越来越AUTHCODE和RegistartionId后,我试图发送消息。
我是否缺少任何步骤?