$deviceToken, 'collapse_key' => $collapseKey, 'data.message' => $messageText, 'delay_while_idle' => false, 'time_to_live' => 108, 'message_id' => uniqid('nerd_')); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://android.googleapis.com/gcm/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); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (curl_errno($ch)) { //request failed return false;//probably you want to return false } if ($httpCode != 200) { //request failed return false;//probably you want to return false } curl_close($ch); $arr = array ('response'=>$response); echo json_encode($arr); return $response; } if (isset($_POST['deviceToken'])) { sendMessageToPhone(); } ?>