periodos.v1.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5. $ruta = "../";
  6. require_once '../include/bd_pdo.php';
  7. $curl = curl_init();
  8. global $db;
  9. curl_setopt_array($curl, [
  10. CURLOPT_URL => "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/periodos/v1/seleccionar",
  11. CURLOPT_RETURNTRANSFER => true,
  12. CURLOPT_POSTFIELDS => "",
  13. CURLOPT_HTTPHEADER => [
  14. "token: 64293fb86c06e45331ab9963822762f77b9c403ca949adcc31286d550e902fff202e4c69d1574b2082ecf0b3a28b6cfd4d88b3a7d2c2ab7d329666b9a527fb1b",
  15. "username: SGU_APSA_AUD_ASIST"
  16. ],
  17. ]);
  18. $response = curl_exec($curl);
  19. $err = curl_error($curl);
  20. curl_close($curl);
  21. if ($err)
  22. die("cURL Error #:$err");
  23. $data = json_decode($response, true);
  24. $in_db = array_map(function ($item) use ($db) {
  25. $item['in_db'] = $db->where('id_periodo_sgu', $item['IdPeriodo'])->has('periodo');
  26. return $item;
  27. }, $data);
  28. $selectedData = array_unique($in_db, SORT_REGULAR);
  29. // Output the selected data directly
  30. header('Content-Type: application/json');
  31. echo json_encode($selectedData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);