<?php 
	require ('conexion.php');
	
	$consulta = 'UPDATE wc_token SET estado = 3 WHERE id = 1;';
	$mysqli->query($consulta);
	
	require ('fe_consultasbd.php'); 
	require ('../funciones/log.php');
			
	$curl = curl_init();
	curl_setopt_array($curl, array(
		CURLOPT_URL => $parametros['urlTokenClose'],
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_ENCODING => '',
		CURLOPT_MAXREDIRS => 10,
		CURLOPT_TIMEOUT => 30,
		CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		CURLOPT_CUSTOMREQUEST => 'POST',
		CURLOPT_POSTFIELDS => http_build_query([
			'client_id'     =>  $parametros['client_id'],
			'refresh_token' =>  $resultadoToken['refresh_token']
		]),
		CURLOPT_HTTPHEADER => array(
			'cache-control: no-cache',
			'content-type: application/x-www-form-urlencoded'
		),
	));
		
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	
	$respuesta = curl_exec($curl);
	$err = curl_error($curl);
	$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
	curl_close($curl);
	if($status == 204 ){
		setLog('CS: CERRAR SESION Correcto code:'. $status,true);
	}else{
		setLog('CS: CERRAR SESION Incorrecto code:'. $status,true);
		var_dump($respuesta);
	}
	
	$consulta = 'UPDATE wc_token SET estado = '.$status.' WHERE id = 1;';
	if($mysqli->query($consulta))
		setLog('CS: Estado de sesion modificado a :'. $status,true);
	
	
	
	
	
	
	
	
		