Introduction
This is a quick and easy example of how to use the BOS Rest services in PHP. It is by no means production worthy and is just a very simple example that returns the telephone number of the queried BOS user. There is no error handling etc.
Assumptions
The example assumes the following:
- The base url is http://bos2.bulletinwireless.net/newrest/REST/BOS/Customer/username/
.
- A valid BOS user is being queried.
- A valid authorised BOS user is making the query.
- The PHP script is located at http://webmail.bulletin.net/temp/sample.php
.
Components
The first component of the example is a very basic HTML form used to submit the BOS user we want to query and the authorised user name and password submitting the query. The source code is below:
The second component of the example is the PHP script. The script does the following:
- Gets the username, userid and password from the HTML form.
- Builds the url to submit.
- Submits the url and gets a response.
- Loads the response as an XML string.
- Queries the namespace referred to in the returned XML string
- Gets all elements in the XML.
- Gets and prints the telephone number element.
The source code for the script is below:
Try it.
To try the example enter a valid BOS username to query, a valid BOS userid making the query and password for the userid, then click the submit button.
You should see a plain page with the following:
The phone number for BOS user (username you entered) is (whatever phone number is)