0
我正在開發使用C2DM的應用程序。我已收到註冊ID。我如何將它發送到服務器。任何人都可以用代碼解釋我嗎?的Android C2DM應用
我正在開發使用C2DM的應用程序。我已收到註冊ID。我如何將它發送到服務器。任何人都可以用代碼解釋我嗎?的Android C2DM應用
這裏是一個PHP函數發送C2DM消息到手機,與註冊ID。
/** * 發送消息到手機。
功能sendMessageToPhone($ AUTHCODE, $ deviceRegistrationId,$ MSGTYPE, $ MessageText中){
$headers = array('Authorization: GoogleLogin auth=' . $authCode); $data = array( 'registration_id' => $deviceRegistrationId, 'collapse_key' => $msgType, 'data.message' => $messageText ); $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); // for debugging the request //curl_setopt($ch, CURLINFO_HEADER_OUT, true); // for debugging the request $response = curl_exec($ch); // for debugging the request //var_dump(curl_getinfo($ch)); // var_dump($response); curl_close($ch); return $response; }
您好Vishwa我也在做一個工作,在Android的C2DM發送通知,但現在我無法得到registrationnid形式c2dm服務器,你在你的問題中提到你有一個註冊ID請提供獲取註冊ID的代碼。在此先感謝..請請幫助我.. – DynamicMind 2011-03-10 09:53:53