periodos.v1.php 1.1 KB

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