-
Notifications
You must be signed in to change notification settings - Fork 60
Output
For a web service to be able to send results back to Unicorn, it needs to implement a specific format called an observation response. Basically, this is an XML document listing all the messages (errors, warnings and information) that the web service produced.
The following code shows how such a response would look like for the calculator. It contains two normal messages and an error. As you can see, each message has a type (info, warn, error), a context (optional) and a title. In our case, the context contains the arithmetic expression and the title contains the corresponding result. Each message element can have more data, like a longer text, an associated group, ... As you can see, there's also a status which is used to express if the test succeeded or failed. For a detailed description of this format check out its dedicated documentation.
So, back to our calculator, we already have our results in an array and errors in another one, so it's easy to turn them into a Unicorn response:
Finally, we add it to the list of supported outputs in our main PHP script:
Et voilà, we can now call the calculator with the parameter output=ucn to get results in Unicorn format.
The [wiki:ObserverTutorial/Contract] as an observer developper will be to tell Unicorn how it can contact the service and which parameters to use. This is what we call the contract.
Use an extra layer of security with two factor authentication (2FA) when logging into google