Connection and security key
The authentication mechanism for the webservices is a little weird, so let us first give you an example of how we would go about to call a service that creates a user in Chamilo from another application in PHP... we'll then explain the different parts.
At the very beginning, we formed the URL to access the WSDL. Most of the files in main/webservices/ (if not all) can be called with a «?wsdl » suffix to show the WSDL (the structured presentation of the available functions). This should be enough for any SOAP client to know which functions are available to call.
We then looked for an IP address at testip.php. This script is specifically there to help us form the secret key : we need to show the server we know from what IP we'll be calling. Using file_get_contents() gives you that information into a variable.
We then define a key... that's because we can't get it directly from Chamilo through the webserver. We have to open the app/config/configuration.php file and look for $_configuration['security_key'], then copy its value into our script in order to form the final secret key that we will send to the web service.
Finally, we prepare the $params array and call the WSCreateUserPasswordCrypted() (a special version of WSCreateUser() that only works if we use the same crypt method for the password on both sides (we have to mention it in the encrypt_method parameter.
The parameter original_user_id_name is what allows us to link between Chamilo and our external service. Just give a constant name that represents your system and the fact that it is a user ID, and give the user ID from your system inside the value of original_user_id_value. With this value set, you will later be able to edit or delete users you previously created: Chamilo will maintain a relationship between your system and itself thanks to the storing of this information.
Last updated