sigo con la dichosa api y la tarea es que me muestre los expedientes presentados por un determinado profesional. Esta parte logro hacerla, pero cuando quiero mostrar los resultados, me salen unos array vacíos que no se como limpiarlos.
Adjuto una parte de la respuesta de la api
{ "meta": { "total-records": 9, "total-pages": 1, "records-on-this-page": 9 }, "data": [ { "type": "KNN_TareasExpediente", "id": "2d59b439-5dcb-e5f5-fe29-5d4c8223df6f", "attributes": { "name": "PROYECTO/DT/RT - ARCOR SA.", "date_entered": "2019-08-08T20:15:00+00:00", "date_modified": "2019-08-08T20:15:00+00:00", "modified_user_id": "f01d0b79-ecf0-073f-de47-5b5f4c9970b7", "modified_by_name": "Martin Diaz", "created_by": "f01d0b79-ecf0-073f-de47-5b5f4c9970b7", "created_by_name": "Martin Diaz", "description": "", "deleted": "0", "created_by_link": "", "modified_user_link": "", "assigned_user_id": "f01d0b79-ecf0-073f-de47-5b5f4c9970b7", "assigned_user_name": "Martin Diaz", "assigned_user_link": "", "SecurityGroups": "", "numero": "", "matriculado_dni": "", "comitente_nombre": "", "comitente_dni": "", "certificado": "", "fecha_baja": "", "observacion": "", "tarea": "25115", "fecha_alta": "2019-08-08", "recibido_por": "", "aviso": "", "fecha_aviso": "", "regional": "", "porcentaje": "100.00", "monto_honorario": "0.00", "monto_obra": "0.00000000", "carpetas": "3", "obra_direccion": "Jujuy 441", "obra_cp": "5000", "obra_localidad": "cordoba", "rcontratoascensores_c": false, "expediente_fisico_c": false, "estado_de_caja_c": "", "knn_tareasexpediente_documents_1": "", "fecha_salida_c": "2019-08-08", "retirado_por_c": "", "distribuidor_c": "", "obra_c": "AUTOTRANPORTADORA NO MOTORA ", "visador_c": "", "opportunities_knn_tareasexpediente_1": "", "opportunities_knn_tareasexpediente_1_name": "50144 - RODRIGUEZ CARMEN E. - ARCOR SA. - Instalaciones Eléctricas", "opportunities_knn_tareasexpediente_1opportunities_ida": "4fd105ac-1375-9106-346f-5d4c82f9cc4f", "tipo_tarea_c": "PROYECTO/DT/RT", "lbl_regional_ingreso_c": "CBA.", "knn_tareasexpediente_knn_pedido_de_facturacion_1": "", "accounts_knn_tareasexpediente_1": "", "accounts_knn_tareasexpediente_1_name": "RODRIGUEZ CARMEN E.", "accounts_knn_tareasexpediente_1accounts_ida": 557, "nombreretira_c": "Martin Diaz", "ascensores_c": "0", "knn_tareasexpediente_activities_1_emails": "", "fechainicioobra_c": "", "es_epec_c": "0", "knn_tareasexpediente_activities_1_tasks": "", "user_id_c": "", "ersep_c": "", "observacion_tarea_c": "", "knn_tareasexpediente_knn_aportes_terceros_1": "", "knn_tareasexpediente_activities_1_notes": "", "knn_comitente_knn_tareasexpediente_1": "", "knn_comitente_knn_tareasexpediente_1_name": "ARCOR SA.", "knn_comitente_knn_tareasexpediente_1knn_comitente_ida": "e70611883d2760c8bbafb4acb29e3446", "documentacionit_c": "", "es_ersep_c": "0", "knn_tareasexpediente_aos_pdf_templates_1": "", "epec_c": "", "es_particular_c": "0", "migrada_c": "1", "esta_en_sector_c": "", "knn_tareasexpediente_activities_1_meetings": "", "knn_tareasexpediente_activities_1_calls": "", "estado_tarea_c": "Pendiente", "nro_caja_c": "", "fechadeingresoersep_c": "", "registro_digital_c": "" }, "links": { "self": "V8/module/KNN_TareasExpediente/2d59b439-5dcb-e5f5-fe29-5d4c8223df6f" } }, { "type": "KNN_TareasExpediente", "id": "3edc1fd9-05a4-de93-1bbe-627c1f2b2d58", "attributes": { "name": " - ", "date_entered": "2022-05-11T20:42:00+00:00", "date_modified": "2022-05-11T20:42:00+00:00", "modified_user_id": "62365376-2acd-faea-1a26-6272c2cd9f18", "modified_by_name": "Alejandro Arla WEB", "created_by": "62365376-2acd-faea-1a26-6272c2cd9f18", "created_by_name": "Alejandro Arla WEB", "description": "", "deleted": "0", "created_by_link": "", "modified_user_link": "", "assigned_user_id": "", "assigned_user_name": "", "assigned_user_link": "", "SecurityGroups": "", "numero": "", "matriculado_dni": "", "comitente_nombre": "", "comitente_dni": "", "certificado": "", "fecha_baja": "", "observacion": "", "tarea": "55588", "fecha_alta": "2022-05-11", "recibido_por": "", "aviso": "", "fecha_aviso": "", "regional": "", "porcentaje": "0.00", "monto_honorario": "0.00", "monto_obra": "0.00000000", "carpetas": "3", "obra_direccion": "Laprida 105 7a", "obra_cp": "", "obra_localidad": "", "rcontratoascensores_c": "0", "expediente_fisico_c": "0", "estado_de_caja_c": "", "knn_tareasexpediente_documents_1": "", "fecha_salida_c": "", "retirado_por_c": "", "distribuidor_c": "", "obra_c": "", "visador_c": "", "opportunities_knn_tareasexpediente_1": "", "opportunities_knn_tareasexpediente_1_name": "50163 - RODRIGUEZ CARMEN E. - ARLA ALEJANDRO - Ambiente", "opportunities_knn_tareasexpediente_1opportunities_ida": "a3dea485-bdf1-0cfc-cba9-627c1fbabff5", "tipo_tarea_c": "", "lbl_regional_ingreso_c": "", "knn_tareasexpediente_knn_pedido_de_facturacion_1": "", "accounts_knn_tareasexpediente_1": "", "accounts_knn_tareasexpediente_1_name": "RODRIGUEZ CARMEN E.", "accounts_knn_tareasexpediente_1accounts_ida": 557, "nombreretira_c": "", "ascensores_c": "0", "knn_tareasexpediente_activities_1_emails": "", "fechainicioobra_c": "", "es_epec_c": "0", "knn_tareasexpediente_activities_1_tasks": "", "user_id_c": "", "ersep_c": "", "observacion_tarea_c": "", "knn_tareasexpediente_knn_aportes_terceros_1": "", "knn_tareasexpediente_activities_1_notes": "", "knn_comitente_knn_tareasexpediente_1": "", "knn_comitente_knn_tareasexpediente_1_name": "", "knn_comitente_knn_tareasexpediente_1knn_comitente_ida": "", "documentacionit_c": "", "es_ersep_c": "0", "knn_tareasexpediente_aos_pdf_templates_1": "", "epec_c": "", "es_particular_c": "0", "migrada_c": "0", "esta_en_sector_c": "", "knn_tareasexpediente_activities_1_meetings": "", "knn_tareasexpediente_activities_1_calls": "", "estado_tarea_c": "Pendiente", "nro_caja_c": "", "fechadeingresoersep_c": "", "registro_digital_c": "" }, "links": { "self": "V8/module/KNN_TareasExpediente/3edc1fd9-05a4-de93-1bbe-627c1f2b2d58" } },
Estimo que los array vacíos corresponden a lo que me muestra en meta: y yo lo que quiero que recorra el array a partir de data. El código es este:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL =>
'https://devphp7.democrm.com.ar/crmciec712/Api/V8/module/Accounts/'.$id.'/...,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer '.$permiso,
),
));
$response = curl_exec($curl);
curl_close($curl);
$datos1 = json_decode($response, true);
foreach ($datos1 as $valor) {
for ($i = 0; $i < count($valor); $i++) {
$name = $valor[$i]['id'];
$expe = $valor[$i]['attributes']['name'];
$tarea = $valor[$i]['attributes']['tipo_tarea_c'];
$estado = $valor[$i]['attributes']['estado_tarea_c'];
echo "
id expediente: $name<br>
Expediente: $expe<br>
Tarea: $tarea<br>
Estado: $estado <br><br>";
}
}
el resultado es este:
id expediente: Expediente: Tarea: Estado:
id expediente: Expediente: Tarea: Estado:
id expediente: Expediente: Tarea: Estado:
id expediente: 2d59b439-5dcb-e5f5-fe29-5d4c8223df6f Expediente: PROYECTO/DT/RT - ARCOR SA. Tarea: PROYECTO/DT/RT Estado: Pendiente
Gracias por la ayuda.