periodos.v2.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. global $db;
  8. $curl = curl_init();
  9. curl_setopt_array($curl, [
  10. CURLOPT_URL => "https://portal.ulsa.edu.mx/servicios/AuditoriaAsistencialRest/AuditoriaAsistencialService.svc/auditoriaAsistencial/catalogos/periodos/v2/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. $json = json_decode($response, true);
  24. $selectedData = array_map(function ($item) use ($db) {
  25. $item['in_db'] = $db->where('carrera_nombre', $item['NombreCarrera'], 'ILIKE')->has('carrera');
  26. $item['linked'] = $db->where('clave_carrera', $item['ClaveCarrera'], 'ILIKE')->has('carrera');
  27. return $item;
  28. }, $json);
  29. // Output the selected data directly
  30. header('Content-Type: application/json');
  31. echo json_encode($selectedData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);