Nessun risultato
Non ci sono oggetti corrispondenti alla tua ricerca... Controlla che l'ortografia delle parole sia corretta o espandi la ricerca per ottenere risultati!
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] => Link (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.
Questo argomento è datato oltre 6 mesi, non è più possibile rispondere.
Impostazioni dei cookie
Informazioni sui cookie
Il nostro sito utilizza i cookie per le seguenti finalità: fornirvi i servizi che avete richiesto, garantire la sicurezza della nostra piattaforma, ricordare le vostre preferenze per rendere più piacevole la vostra navigazione, compilare statistiche per adattare il nostro sito alle vostre esigenze, visualizzare video e permettervi di condividere contenuti sui social network.
Alcuni di questi cookie sono necessari per il funzionamento del nostro sito, altri possono essere impostati secondo le vostre preferenze.
Per saperne di più