<?php 


 // include db connect class
require_once __DIR__ . '/db_connect.php';

// connecting to db
$db = new DB_CONNECT();
 

$id=""; 
 



    $email="velgun.rs@gmail.com";
    $assign_id="dddss";
    
 $result = mysql_query("SELECT firebase_token FROM signupdetails WHERE emailid = '$email' ");
 
  if (mysql_num_rows($result) > 0) {
	
		 while ($row = mysql_fetch_array($result)) {
		
          //  $result = mysql_fetch_array($result);
            $url= array();
            $id = $row["firebase_token"];
            echo $id;
		 
		 }
  }
 
 
 $message="New task assigned";
 
     //echo $id;

 $url = 'https://fcm.googleapis.com/fcm/send';

    $fields = array (
            
            'data' => array (
                    "assignid" => $assign_id,
                    "taskid" => "Mobitech_t_de_38",
                    "body" => "old Task Assigned",
                    "type" => "new",
                    "dateandtime" => "0200-00-00 00:00:00"

                    ),
            'to' =>$id
    );
    $fields = json_encode ( $fields );

    $headers = array (
            'Authorization:key=AAAABd_t6Zc:APA91bEeWqoBNL4kKPeXdKQVApp1Ot_zdLj2U2Pt6GEAPzI8V2yLTKzFoBam0hGUyfFhwsxMYVrK9whBvPgNjwdMoLIKeNb-hsNgoHAB4yTZg58pX3_4h38Bxkp0Pvw46bRmp3QJUe0B',
            '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_POSTFIELDS, $fields );

    $result = curl_exec ( $ch );
    echo $result;
    curl_close ( $ch );
    

    
?>