Aucun résultat
Il n'y a pas d'objets correspondant à votre recherche... Vérifiez que l'orthographe des mots est correcte ou élargissez votre recherche pour obtenir des résultats !
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] => Lien (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.
Ce sujet datant de plus de 6 mois, il n'est plus possible d'y répondre.
Paramètres des cookies
Information concernant les cookies
Notre site utilise des cookies pour les finalités suivantes : vous fournir les services demandés, assurer la sécurité sur notre plateforme, garder en mémoire vos préférences afin de rendre votre navigation plus agréable, réaliser des statistiques dans le but d’adapter notre site à vos besoins, afficher des vidéos et vous permettre de partager du contenu sur les réseaux sociaux.
Certains de ces cookies sont nécessaires au fonctionnement de notre site, d’autres peuvent être paramétrés selon vos préférences.
En savoir plus