-
Notifications
You must be signed in to change notification settings - Fork 483
Chamilo APIs
The following documentation gives a description (although somewhat outdated) of the behaviour of the Chamilo Web Services. In this APIv1, mostly focused on administrative actions, we use SOAP as a Web Service application protocol (although it would be easy to extend to other protocols). As such, all communication should be sent using SOAP headers and received using a SOAP parser.
An APIv2 is also available (but not yet documented) only for basic webservices in main/webservices/api/v2.php. This API works in REST and serves to feed the mobile application of Chamilo.
If you want to know about more Chamilo web services, please check the main/webservices/ folder in Chamilo. Many scripts are available there for your use as API.
Web services as documented below are available since version 1.9 of Chamilo.
The 'secret_key' is a mandatory parameter to connect to the web services. It is composed of the $_configuration['secret_key'] value inside of the LMS's main/inc/conf/configuration.php file (which can be changed at will, as it is only used for web services at the time of writing) and the IP address of the caller.
For example, if I am calling the webservice from an IP address of 134.23.25.34, I will have to generate an SHA1 encrypted string from this IP addess with the secret key. This can be done for example, in PHP, through the command:
$security_key = 'abcdef1234567890';
$ip_address = '134.23.25.34';
$secret_key = sha1($ip_address.$security_key);
The $secret_key variable must be added manually to the Web Service caller script. It acts as a shared key. Please note that, with the shared key, any attacker could do serious damage to your web server through web services. Keep this key safe!
Calling the SOAP web services scripts is generally done through a URL of this kind: https://campus.chamilo.org/main/webservices/registration.soap.php. You can check the list of available functions through a call to https://campus.chamilo.org/main/webservices/registration.soap.php?wsdl
Getting the right IP address can sometimes be tricky. This should be the public IP address of the server calling Chamilo web services, or at least it should be the IP address as the Chamilo server sees it.
You can check how your IP is detected by the server, calling the http://campus.chamilo.org/main/webservices/testip.php script. The first line can be cut and used as the IP address to put in the $ip_address variable above (just remove the end-of-line character at the end of the first line).
For most Web Services provided, an identifier and a value are expected by Chamilo. For example, if you import your users from an Oracle database, you might use a unique ID coming from the LUSERID field and worth 1504. When calling Chamilo, we assume you will give us the user ID as you know it in your system.
That is, we expect you'll give us LUSERID as the user_id_field_name parameter, and 1504 as the user_id_value.
When you do that, Chamilo is able to find, inside its database, which user you are referring to, because Chamilo kept this reference (inside the extra_field_values
table) when you created the user (or course, or session).
registration.soap.php is the main web services script for APIv1. Although it's not the only one, it at least provides the following methods... (and probably a few more)
Disables one user
array(
'secret_key' => 'abcdef1234567890',
'user_id_field_name' => 'external_user',
'user_id_value' => '1504',
);
nothing (or error message)
Disables several users in one call.
array(
'secret_key' => 'abcdef1234567890',
array(
0=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1504'),
1=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1582'),
)
);
array(
0=>array('code'=>0,'message'=>'Operation was successful'),
1=>array('code'=>0,'message'=>'Operation was successful'),
);
Enables one user
array(
'secret_key' => 'abcdef1234567890',
'user_id_field_name' => 'external_user',
'user_id_value' => '1504',
);
nothing (or error message)
Enables several users in one call.
array(
'secret_key' => 'abcdef1234567890',
array(
0=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1504'),
1=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1582'),
)
);
array(
0=>array('code'=>0,'message'=>'Operation was successful'),
1=>array('code'=>0,'message'=>'Operation was successful'),
);
Deletes one user
array(
'secret_key' => 'abcdef1234567890',
'user_id_field_name' => 'external_user',
'user_id_value' => '1504',
);
nothing (or error message)
Deletes several users in one call
array(
'secret_key' => 'abcdef1234567890',
array(
0=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1504'),
1=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1582'),
)
);
array(
0=>array('code'=>0,'message'=>'Operation was successful'),
1=>array('code'=>0,'message'=>'Operation was successful'),
);
Creates one user
array(
'secret_key' => 'xsd:string',
'firstname' => 'xsd:string',
'lastname' => 'xsd:string',
'status' => 'xsd:int',
'loginname' => 'xsd:string',
'password' => 'xsd:string',
'encrypt_method' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'visibility' => 'xsd:int',
'email' => 'xsd:string',
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:extra_field[]'
);
int new_user_id
Creates several users in one call.
array(
'secret_key' => 'xsd:string',
array(
0 => array(
'firstname' => 'xsd:string',
'lastname' => 'xsd:string',
'status' => 'xsd:int',
'loginname' => 'xsd:string',
'password' => 'xsd:string',
'encrypt_method' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'visibility' => 'xsd:int',
'email' => 'xsd:string',
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:extra_field[]'
),
1 => array(
'firstname' => 'xsd:string',
'lastname' => 'xsd:string',
'status' => 'xsd:int',
'loginname' => 'xsd:string',
'password' => 'xsd:string',
'encrypt_method' => 'xsd:string',
'user_id_field_name' => 'xsd:string',
'user_id_value' => 'xsd:string',
'visibility' => 'xsd:int',
'email' => 'xsd:string',
'language' => 'xsd:string',
'phone' => 'xsd:string',
'expiration_date' => 'xsd:string',
'extras' => 'tns:extra_field[]'
)
)
);
array(
0 => array(
'result' => 'xxx',
'user_id_value' => 1504,
'user_id_generated' => 1
),
1 => array(
'result' => 'xxx',
'user_id_value' => 1504,
'user_id_generated' => 1
),
);
Edits one user
Edits several users in one call.
Deletes one course
Deletes several courses in one call.
Creates one course
Creates several courses in one call.
Edits one course
Lists courses
Subscribes one user to one course
Unsubscribes one user from one course.
Gets the list of course descriptions.
Edits one description of one course.
Creates one session.
Deletes one session.
Edits one session.
Subscribes one user to one session.
Unsubscribes one user from one session
Subscribes one course to one session.
Unsubscribes one course from one session
-
Home
- Tools and sessions
- Quiz: Importing
- Releases
- Community support strategy
- Translation management
- How to report issues
- Development
- Integration