J'ai obtenu registration_id
et authoCode
en utilisant le même ID gmail, mais je reçois toujours "non autorisé". Je suis désemparé maintenant ce qui peut être faux. Lors de l'inscription à Android Cloud to Device Messaging. Si j'utilise [email protected], je me sers même [email protected] dansAndroid 401 pour c2dm
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);
même pour le tout en obtenant AUTHCODE
https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&[email protected]&Passwd=XXXXX&source=XXXXXXX-0.1&service=cl
code J'utilise est
$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;
Ce sont les étapes que je suivis
- J'ai créé un nouveau googl compte e pour mon application
- inscrit avec http://code.google.com/android/c2dm/signup.html
- d'abord couru l'application sur le simulateur pour obtenir le numéro d'inscription
- utilisé le même identifiant gmail pour obtenir le code d'autorisation
- Après avoir AUTHCODE et RegistartionId, je suis essayer d'envoyer le message.
Ai-je manqué des étapes?