Run php code online for android push notification

Run php code online for android push notification

To Test push notification code online run below code with replace of $deviceTocken and $GOOGLE_API_KEY

To create API_KEY click here



 echo("Send notification");

 	$type = 'TEST';
	$greetMsg = 'Demo Notification';
	$respJson = '{"type":"'.$type.'","message":"'.$greetMsg.'"}';
$registation_ids = array();
$deviceTocken = '';
		array_push($registation_ids, $deviceTocken);

 echo("Send notification\n\n=====");
	//Google cloud messaging GCM-API url
        $url = '';
        $fields = array(
            'registration_ids' => $registation_ids,
            'data' => json_decode($respJson),
		// Update your Google Cloud Messaging API Key
		if (!defined('GOOGLE_API_KEY')) {
			define("GOOGLE_API_KEY", $GOOGLE_API_KEY); 		
        $headers = array(
            'Authorization: key=' . GOOGLE_API_KEY,
            'Content-Type: application/json'
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);	
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
        $result = curl_exec($ch);				
        if ($result === FALSE) {
            die('Curl failed: ' . curl_error($ch));
     echo("responce co================= $result" + $result );


Then copy code from here to and past code in site and press run button.

Add a Comment