<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\http\Request;
use Illuminate\http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Input;
use Hash;


use DB;


class NotifsController extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    public function TestNotif(Request $request)
    {
		
		function sendNotification_now($reg_id1,$message1)
		{
   
			define( 'API_ACCESS_KEY', 'AAAAu9ffgsQ:APA91bFdS6uKxRx5xf22NPln8RZ2Wm-YqIzlt3iIIAAMgBmaJn14KvWkY9qqaTYEnWvezb8n36cYeAHaW_y69p9dsNDrSHGTP4Y7gg_5bNpQ6DNiAcZpC9bHkUAA9RqOq6DtwMCC9ER4' );
			$registrationIds = array( $reg_id1 );
			$fields = array
			(
				'registration_ids' 	=> $registrationIds,
				'data'			=> $message1
			);
			 
			$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_SSL_VERIFYPEER, false );
			curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
			$result = curl_exec($ch );
                        echo $result;
			curl_close( $ch );
			return $result;
				
		}
		
		$msgtype1="notification";	
		$msg1 = array
		(
			'message' 	            => "Added you as mentor",
			'notification_type' 	=> $msgtype1,
			'vibrate'				=> 1,
			'sound'					=> 1
		);
		$device_id1="fSI3acd_nMU:APA91bHrAP1D4bqNtPxhDuhWd-V8JB_ngWO4eCGLsE_mWT1j5RQ20Wo5fgn1JeYD_d_sbatEDMnWgLg111pnoeHYFO-Qc2vwZSItZbqwpbZnBJrOPArUf6dqswu9ybDZmgO6eQ_7wvf-";
		sendNotification_now($device_id1,$msg1);
            
    }


}

