Ningún resultado
No hay artículos que coincidan con su búsqueda... ¡Compruebe que la ortografía de las palabras es correcta o amplíe su búsqueda para obtener resultados!
Hi there,
I have a problem with the notification settings results.
I call the notification/settings and the results are:
...
[body] => SimpleXMLElement Object
(
[notification_settings] => Array
(
[0] => SimpleXMLElement Object
(
[id_notification] => xxxxxxx
[id_user] => yyyyyy
[channel] => Curl
[type] => Curl_Default
[destination] => Vinculo (https)
.....
[active] => 1
)
And so on.
The problem is that I'm not able to iterate through the notification_settings elements.
If I call the gettype($xml->Notification_Data->body->notification_settings) it returns "object"
I'm a bit confused. Does someone have suggestions?
Thanks for the help.
OK, I'm able to iterate through the notification_settings elements usin a foreach loop.
Now the question is: does the call always returns array? Even if there is only 1 setting?
Otherwise I think the foreach will raise an exception.
Thank you
Daniele
Hi there,
I use this topic to post another question:
If a notification setting is active like elemt 0 above, the "active" is set to 1. That make sense.
If a notification setting is NOT active like elemt 1 above, the "active" is set to "SimpleXMLElement Object". I wonder why not set this value to 0.
Hi there,
I use this topic to post another question:
If a notification setting is active like elemt 0 above, the "active" is set to 1. That make sense.
If a notification setting is NOT active like elemt 1 above, the "active" is set to "SimpleXMLElement Object". I wonder why not set this value to 0.
The call will not always returns an array since it depends on the library used to read the XML. With your library you use, if there are several elements it will be an array otherwise it will return a SimpleXMLElement Object. But the PHP foreach will handle this well, no worries.
If the notification is inactive the tag 'active' will be empty. It is still your library that parse empty fields into SimpleXMLElement Object.
Sorry for the late response, I hope I have answered your questions.
Hi Thomas,
thank you for the reply.
I added some line of code and it works fine.
However I think that returning an empty field on a logical element is a bug, not a feature.
Empty does not match true nor false. An [active] field should be true(1) or false (0).
Regards
Daniele
Hi Thomas,
thank you for the reply.
I added some line of code and it works fine.
However I think that returning an empty field on a logical element is a bug, not a feature.
Empty does not match true nor false. An [active] field should be true(1) or false (0).
Regards
Daniele
I'm glad to read that you've managed to make it work.
You are right: we should not return an empty field. Unfortunately that's the way it was done back then and now many systems have been built that way. That's why we won't change this behaviour.
I hope you understand this decision, forgive us for the inconvenience.
Este tema ha sido creado hace más de 6 meses, ya no puede responderle.
Configuración de las cookies
Información sobre las cookies
Nuestra web utiliza cookies con los siguientes fines: prestarle los servicios que nos haya solicitado, garantizar la seguridad de nuestra plataforma, recordar sus preferencias para hacer más agradable su navegación, elaborar estadísticas para adaptar nuestra web a sus necesidades, mostrar vídeos y permitirle compartir contenidos en las redes sociales.
Algunas de estas cookies son necesarias para el funcionamiento de nuestro sitio web, otras pueden establecerse según sus preferencias.
Más información