Following the weather magnet challenge (Weather Magnet) a more involved challenge was issued. Use the user control BAPIs to allow a PHP interface to the users.
The competition prizes are still on offer, a chance to get your hands on a copy of Zend Studio and PHP 5 book.
The following 3 code samples provide a stepping stone for the PHP User control. The examples concentrate on the interaction with the backend and leave the presentation aspects open to creativity.
The BAPIs available are:
BAPI_USER_DISPLAY (This may not be so useful in this scenario)
The example implements only the BAPI_USER_GET_DETAIL method, the rest are left to the imagination of the contestant.
The code is separated into two classes, one for the user and one for backend access. The backend access uses the BAPIs provided as Web Services. It you want to use RFC then simply replace this class with one that implements the RFC interface.
The first piece is simply a test script to display the contents of the user class to the user.
Simple example to show some user data. If you want to change the username at runtime you can specify the user in the URL e.g. showusers.php?user=ME The last name of $username is “.$user->getLastName(); //print_r($user); ?>
This provides the beginnings of a class to represent a single user. An instance is populated via calls to the static methods of the backend class.
This is the interface to the backend system. The implementation uses the BAPI as a webservice..
“; echo $exception; echo “
“, htmlspecialchars($client->__getLastRequest()), “
“; echo “Response :
“, htmlspecialchars($client->__getLastResponse()), “
“; } } } ?>