<?php
include '../../conn.php';
include 'message.php'; 

$userid=$_GET['userid'];
$membershipid=$_GET['membershipid'];

 
$update = $con->query("UPDATE `users` SET `memberShip`='$membershipid' , `membershipTime`=NOW()  WHERE  id='$userid'");


if($update > 0)
{ 
    
 
      
      $data = array("to" => $fcmtoken,
                  "notification" => array( "code"=> $membershipcode,"title" => "$titlefcm", "body" => $membershipmsg,"icon" => $logofcm));                                                                    
            $data_string = json_encode($data); 
            
             "The Json Data : ".$data_string; 
            
            $headers = array
            (
                 'Authorization: key=' . API_ACCESS_KEY, 
                 'Content-Type: application/json'
            );                                                                                 
                                                                                                                                 
            $ch = curl_init();  
            
            curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );                                                                  
            curl_setopt( $ch,CURLOPT_POST, true );  
            curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
            curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
            curl_setopt( $ch,CURLOPT_POSTFIELDS, $data_string);                                                                  
                                                                                                                                 
            $result = curl_exec($ch);
$j->status  = "101";
$j->message = "Success";
}
else{
$j->status  = "104";
$j->message = "Email And Password wrong";
}
echo json_encode($j);         
?>