Project

General

Profile

Web services » History » Version 12

Yannick Warnier, 26/02/2015 18:52

1 12 Yannick Warnier
h1. Web services / API
2 6 Yannick Warnier
3 2 Yannick Warnier
{{>toc}}
4 3 Yannick Warnier
5 10 Yannick Warnier
h2. Introduction
6 1 Yannick Warnier
7 12 Yannick Warnier
The following documentation gives a description (although somewhat outdated) of the behaviour of the Chamilo Web Services.
8 1 Yannick Warnier
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.
9
10
To use Chamilo's [[webservices from systems written in python]], you can use web2py as described in this link.
11 12 Yannick Warnier
12
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.
13 10 Yannick Warnier
14 11 Yannick Warnier
h2. Chamilo > 1.8.8.4
15
16
Please check the introduction to Chamilo > 1.8.7 first
17
18
h3. WSUser.EditUserCredentials
19
20
Edits the username and/or (unencrypted) password
21
22
h4. Input
23
24
<pre>
25
array(
26
 'secret_key' => 'abcdef1234567890',
27
 'user_id_field_name' => 'external_user',
28
 'user_id_value' => '1504',
29
 'username' => 'slee',
30
 'password' => 'abcdef'
31
);
32
</pre>
33
34
h4. Output
35
36
<pre>
37
1 (or -1 on failure)
38
</pre>
39
40
41 10 Yannick Warnier
h2. Chamilo > 1.8.7
42
43 6 Yannick Warnier
44
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, it is only used for web services at the time of writing) and the IP address of the caller.
45
46
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:
47
<pre>$security_key = 'abcdef1234567890';
48
$ip_address = '134.23.25.34';
49
$secret_key = sha1($ip_address.$security_key);</pre>
50
51
The $secret_key variable must then be added to the Web Service call.
52
53
Calling the SOAP web services scripts is generally done through a URL of this kind:
54
http://campus.chamilo.org/main/webservices/soap.php. You can check the list of available functions through a call to http://campus.chamilo.org/main/webservices/soap.php?wsdl
55
56
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
57
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).
58
59 8 Yannick Warnier
h3. External identifiers
60
61
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*.
62
63
When you do that, Chamilo is able to find, inside its database, which user you are referencing, because Chamilo kept this reference at the time of calling.
64
65 6 Yannick Warnier
h3. WSUser.DisableUser
66
67
Disables one user
68 1 Yannick Warnier
69 8 Yannick Warnier
h4. Input
70
71 1 Yannick Warnier
<pre>
72 8 Yannick Warnier
array(
73
 'secret_key' => 'abcdef1234567890',
74
 'user_id_field_name' => 'external_user',
75
 'user_id_value' => '1504',
76
);
77 1 Yannick Warnier
</pre>
78
79 8 Yannick Warnier
h4. Output
80
81 6 Yannick Warnier
<pre>
82 8 Yannick Warnier
nothing (or error message)
83 6 Yannick Warnier
</pre>
84
85
h3. WSUser.DisableUsers
86 1 Yannick Warnier
87
Disables several users in one call.
88 6 Yannick Warnier
89 8 Yannick Warnier
h4. Input
90
91 1 Yannick Warnier
<pre>
92 8 Yannick Warnier
array(
93
'secret_key' => 'abcdef1234567890',
94
 array( 
95
  0=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1504'),
96
  1=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1582'),
97
 )
98
);
99 6 Yannick Warnier
</pre>
100 1 Yannick Warnier
101 8 Yannick Warnier
h4. Output
102
103 1 Yannick Warnier
<pre>
104 8 Yannick Warnier
array(
105
  0=>array('code'=>0,'message'=>'Operation was successful'),
106
  1=>array('code'=>0,'message'=>'Operation was successful'),
107
);
108 6 Yannick Warnier
</pre>
109
110
h3. WSUser.EnableUser
111
112 7 Yannick Warnier
Enables one user
113 6 Yannick Warnier
114 9 Yannick Warnier
h4. Input
115
116 1 Yannick Warnier
<pre>
117 9 Yannick Warnier
array(
118
 'secret_key' => 'abcdef1234567890',
119
 'user_id_field_name' => 'external_user',
120
 'user_id_value' => '1504',
121
);
122 1 Yannick Warnier
</pre>
123
124 9 Yannick Warnier
h4. Output
125
126 6 Yannick Warnier
<pre>
127 9 Yannick Warnier
nothing (or error message)
128 7 Yannick Warnier
</pre>
129 6 Yannick Warnier
130 7 Yannick Warnier
h3. WSUser.EnableUsers
131 1 Yannick Warnier
132
Enables several users in one call.
133 6 Yannick Warnier
134 9 Yannick Warnier
h4. Input
135
136 1 Yannick Warnier
<pre>
137 9 Yannick Warnier
array(
138
'secret_key' => 'abcdef1234567890',
139
 array( 
140
  0=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1504'),
141
  1=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1582'),
142
 )
143
);
144 6 Yannick Warnier
</pre>
145 1 Yannick Warnier
146 9 Yannick Warnier
h4. Output
147
148 1 Yannick Warnier
<pre>
149 9 Yannick Warnier
array(
150
  0=>array('code'=>0,'message'=>'Operation was successful'),
151
  1=>array('code'=>0,'message'=>'Operation was successful'),
152
);
153 7 Yannick Warnier
</pre>
154 1 Yannick Warnier
155
h3. WSUser.DeleteUser
156 6 Yannick Warnier
157 1 Yannick Warnier
Deletes one user
158
159 9 Yannick Warnier
h4. Input
160
161 1 Yannick Warnier
<pre>
162 9 Yannick Warnier
array(
163
 'secret_key' => 'abcdef1234567890',
164
 'user_id_field_name' => 'external_user',
165
 'user_id_value' => '1504',
166
);
167 6 Yannick Warnier
</pre>
168
169 9 Yannick Warnier
h4. Output
170
171 7 Yannick Warnier
<pre>
172 9 Yannick Warnier
nothing (or error message)
173 1 Yannick Warnier
</pre>
174 6 Yannick Warnier
175 1 Yannick Warnier
h3. WSUser.DeleteUsers
176
177
Deletes several users in one call
178
179 9 Yannick Warnier
h4. Input
180
181 1 Yannick Warnier
<pre>
182 9 Yannick Warnier
array(
183
'secret_key' => 'abcdef1234567890',
184
 array( 
185
  0=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1504'),
186
  1=>array('user_id_field_name' => 'external_user', 'user_id_value' => '1582'),
187
 )
188
);
189 1 Yannick Warnier
</pre>
190 6 Yannick Warnier
191 9 Yannick Warnier
h4. Output
192
193 6 Yannick Warnier
<pre>
194 9 Yannick Warnier
array(
195
  0=>array('code'=>0,'message'=>'Operation was successful'),
196
  1=>array('code'=>0,'message'=>'Operation was successful'),
197
);
198 1 Yannick Warnier
</pre>
199
200
h3. WSUser.CreateUser
201
202
Creates one user
203
204 9 Yannick Warnier
h4. Input
205
206 1 Yannick Warnier
<pre>
207 9 Yannick Warnier
array(
208
'secret_key' => 'xsd:string',
209
'firstname' => 'xsd:string',
210
'lastname' => 'xsd:string',
211
'status' => 'xsd:int',
212
'loginname' => 'xsd:string',
213
'password' => 'xsd:string',
214
'encrypt_method' => 'xsd:string',
215
'user_id_field_name' => 'xsd:string',
216
'user_id_value' => 'xsd:string',
217
'visibility' => 'xsd:int',
218
'email' => 'xsd:string',
219
'language' => 'xsd:string',
220
'phone' => 'xsd:string',
221
'expiration_date' => 'xsd:string',
222
'extras' => 'tns:extra_field[]'
223
);
224 6 Yannick Warnier
</pre>
225 1 Yannick Warnier
226 9 Yannick Warnier
h4. Output
227
228 1 Yannick Warnier
<pre>
229 9 Yannick Warnier
int new_user_id
230 1 Yannick Warnier
</pre>
231
232
h3. WSUser.CreateUsers
233
234
Creates several users in one call.
235
236 9 Yannick Warnier
h4. Input
237
238 1 Yannick Warnier
<pre>
239 9 Yannick Warnier
array(
240
 'secret_key' => 'xsd:string',
241
 array(
242
  0 => array(
243
   'firstname' => 'xsd:string',
244
   'lastname' => 'xsd:string',
245
   'status' => 'xsd:int',
246
   'loginname' => 'xsd:string',
247
   'password' => 'xsd:string',
248
   'encrypt_method' => 'xsd:string',
249
   'user_id_field_name' => 'xsd:string',
250
   'user_id_value' => 'xsd:string',
251
   'visibility' => 'xsd:int',
252
   'email' => 'xsd:string',
253
   'language' => 'xsd:string',
254
   'phone' => 'xsd:string',
255
   'expiration_date' => 'xsd:string',
256
   'extras' => 'tns:extra_field[]'
257
  ),
258
  1 => array(
259
   'firstname' => 'xsd:string',
260
   'lastname' => 'xsd:string',
261
   'status' => 'xsd:int',
262
   'loginname' => 'xsd:string',
263
   'password' => 'xsd:string',
264
   'encrypt_method' => 'xsd:string',
265
   'user_id_field_name' => 'xsd:string',
266
   'user_id_value' => 'xsd:string',
267
   'visibility' => 'xsd:int',
268
   'email' => 'xsd:string',
269
   'language' => 'xsd:string',
270
   'phone' => 'xsd:string',
271
   'expiration_date' => 'xsd:string',
272
   'extras' => 'tns:extra_field[]'
273
  )
274
 )
275
);
276 1 Yannick Warnier
</pre>
277
278 9 Yannick Warnier
h4. Output
279
280 1 Yannick Warnier
<pre>
281 9 Yannick Warnier
array(
282
 0 => array(
283
  'result' => 'xxx',
284
  'user_id_value' => 1504,
285
  'user_id_generated' => 1
286
 ),
287
 1 => array(
288
  'result' => 'xxx',
289
  'user_id_value' => 1504,
290
  'user_id_generated' => 1
291
 ),
292
);
293 6 Yannick Warnier
</pre>
294
295
h3. WSUser.EditUser
296
297 7 Yannick Warnier
Edits one user
298 1 Yannick Warnier
299 9 Yannick Warnier
h4. Input
300
301 7 Yannick Warnier
<pre>
302 1 Yannick Warnier
</pre>
303
304 9 Yannick Warnier
h4. Output
305
306 6 Yannick Warnier
<pre>
307 1 Yannick Warnier
</pre>
308 6 Yannick Warnier
309
h3. WSUser.EditUsers
310
311 1 Yannick Warnier
Edits several users in one call.
312
313 9 Yannick Warnier
h4. Input
314
315 1 Yannick Warnier
<pre>
316
</pre>
317 6 Yannick Warnier
318 9 Yannick Warnier
h4. Output
319
320 1 Yannick Warnier
<pre>
321 6 Yannick Warnier
</pre>
322
323 9 Yannick Warnier
324 1 Yannick Warnier
h3. WSCourse.DeleteCourse
325
326 6 Yannick Warnier
Deletes one course
327 7 Yannick Warnier
328 9 Yannick Warnier
h4. Input
329
330 6 Yannick Warnier
<pre>
331 7 Yannick Warnier
</pre>
332 6 Yannick Warnier
333 9 Yannick Warnier
h4. Output
334
335 6 Yannick Warnier
<pre>
336
</pre>
337 1 Yannick Warnier
338 9 Yannick Warnier
339 6 Yannick Warnier
h3. WSCourse.DeleteCourses
340
341 1 Yannick Warnier
Deletes several courses in one call.
342
343 9 Yannick Warnier
h4. Input
344
345 7 Yannick Warnier
<pre>
346 1 Yannick Warnier
</pre>
347 6 Yannick Warnier
348 9 Yannick Warnier
h4. Output
349
350 1 Yannick Warnier
<pre>
351
</pre>
352 6 Yannick Warnier
353 9 Yannick Warnier
354 1 Yannick Warnier
h3. WSCourse.CreateCourse
355
356 6 Yannick Warnier
Creates one course
357 7 Yannick Warnier
358 9 Yannick Warnier
h4. Input
359
360 7 Yannick Warnier
<pre>
361 6 Yannick Warnier
</pre>
362
363 9 Yannick Warnier
h4. Output
364
365 6 Yannick Warnier
<pre>
366
</pre>
367 1 Yannick Warnier
368 9 Yannick Warnier
369 6 Yannick Warnier
h3. WSCourse.CreateCourses
370
371
Creates several courses in one call.
372 1 Yannick Warnier
373 9 Yannick Warnier
h4. Input
374
375 7 Yannick Warnier
<pre>
376 1 Yannick Warnier
</pre>
377
378 9 Yannick Warnier
h4. Output
379
380 1 Yannick Warnier
<pre>
381
</pre>
382 6 Yannick Warnier
383 9 Yannick Warnier
384 6 Yannick Warnier
h3. WSCourse.EditCourse
385 1 Yannick Warnier
386 6 Yannick Warnier
Edits one course
387
388 9 Yannick Warnier
h4. Input
389
390 1 Yannick Warnier
<pre>
391 6 Yannick Warnier
</pre>
392
393 9 Yannick Warnier
h4. Output
394
395 6 Yannick Warnier
<pre>
396 7 Yannick Warnier
</pre>
397 6 Yannick Warnier
398 9 Yannick Warnier
399 7 Yannick Warnier
h3. WSCourse.ListCourses
400 6 Yannick Warnier
401
Lists courses
402 1 Yannick Warnier
403 9 Yannick Warnier
h4. Input
404
405 6 Yannick Warnier
<pre>
406 1 Yannick Warnier
</pre>
407
408 9 Yannick Warnier
h4. Output
409
410 6 Yannick Warnier
<pre>
411 1 Yannick Warnier
</pre>
412 6 Yannick Warnier
413 9 Yannick Warnier
414 7 Yannick Warnier
h3. WSCourse.SubscribeUserToCourse
415 1 Yannick Warnier
416
Subscribes one user to one course
417 6 Yannick Warnier
418 9 Yannick Warnier
h4. Input
419
420 1 Yannick Warnier
<pre>
421 6 Yannick Warnier
</pre>
422
423 9 Yannick Warnier
h4. Output
424
425 6 Yannick Warnier
<pre>
426
</pre>
427
428 9 Yannick Warnier
429 1 Yannick Warnier
h3. WSCourse.UnsubscribeUserFromCourse
430 6 Yannick Warnier
431
Unsubscribes one user from one course.
432 1 Yannick Warnier
433 9 Yannick Warnier
h4. Input
434
435 7 Yannick Warnier
<pre>
436 6 Yannick Warnier
</pre>
437 1 Yannick Warnier
438 9 Yannick Warnier
h4. Output
439
440 6 Yannick Warnier
<pre>
441 1 Yannick Warnier
</pre>
442
443 9 Yannick Warnier
444 6 Yannick Warnier
h3. WSCourse.GetCourseDescriptions
445 1 Yannick Warnier
446
Gets the list of course descriptions.
447 6 Yannick Warnier
448 9 Yannick Warnier
h4. Input
449
450 1 Yannick Warnier
<pre>
451 6 Yannick Warnier
</pre>
452
453 9 Yannick Warnier
h4. Output
454
455 1 Yannick Warnier
<pre>
456 6 Yannick Warnier
</pre>
457 7 Yannick Warnier
458 9 Yannick Warnier
459 1 Yannick Warnier
h3. WSCourse.EditCourseDescription
460 6 Yannick Warnier
461
Edits one description of one course.
462
463 9 Yannick Warnier
h4. Input
464
465 6 Yannick Warnier
<pre>
466
</pre>
467 1 Yannick Warnier
468 9 Yannick Warnier
h4. Output
469
470 6 Yannick Warnier
<pre>
471 1 Yannick Warnier
</pre>
472
473 9 Yannick Warnier
474 7 Yannick Warnier
h3. WSSession.CreateSession
475 6 Yannick Warnier
476 1 Yannick Warnier
Creates one session.
477 7 Yannick Warnier
478 9 Yannick Warnier
h4. Input
479
480 1 Yannick Warnier
<pre>
481
</pre>
482 6 Yannick Warnier
483 9 Yannick Warnier
h4. Output
484
485 1 Yannick Warnier
<pre>
486 6 Yannick Warnier
</pre>
487
488 9 Yannick Warnier
489 1 Yannick Warnier
h3. WSSession.DeleteSession
490 6 Yannick Warnier
491
Deletes one session.
492 7 Yannick Warnier
493 9 Yannick Warnier
h4. Input
494
495 6 Yannick Warnier
<pre>
496 7 Yannick Warnier
</pre>
497 1 Yannick Warnier
498 9 Yannick Warnier
h4. Output
499
500 6 Yannick Warnier
<pre>
501
</pre>
502 1 Yannick Warnier
503 9 Yannick Warnier
504 6 Yannick Warnier
h3. WSSession.EditSession
505
506 1 Yannick Warnier
Edits one session.
507
508 9 Yannick Warnier
h4. Input
509
510 1 Yannick Warnier
<pre>
511
</pre>
512 6 Yannick Warnier
513 9 Yannick Warnier
h4. Output
514
515 1 Yannick Warnier
<pre>
516 7 Yannick Warnier
</pre>
517 6 Yannick Warnier
518 9 Yannick Warnier
519 1 Yannick Warnier
h3. WSSession.SubscribeUserToSession
520
521 6 Yannick Warnier
Subscribes one user to one session.
522
523 9 Yannick Warnier
h4. Input
524
525 6 Yannick Warnier
<pre>
526
</pre>
527
528 9 Yannick Warnier
h4. Output
529
530 7 Yannick Warnier
<pre>
531 6 Yannick Warnier
</pre>
532 7 Yannick Warnier
533 9 Yannick Warnier
534 6 Yannick Warnier
h3. WSSession.UnsubscribeUserFromSession
535
536
Unsubscribes one user from one session
537
538 9 Yannick Warnier
h4. Input
539
540 6 Yannick Warnier
<pre>
541
</pre>
542 7 Yannick Warnier
543 9 Yannick Warnier
h4. Output
544
545 6 Yannick Warnier
<pre>
546
</pre>
547
548 9 Yannick Warnier
549 6 Yannick Warnier
h3. WSSession.SubscribeCourseToSession
550
551
Subscribes one course to one session.
552
553 9 Yannick Warnier
h4. Input
554
555 1 Yannick Warnier
<pre>
556
</pre>
557 4 Yannick Warnier
558
h4. Output
559 1 Yannick Warnier
560
<pre>
561 2 Yannick Warnier
</pre>
562
563
564 4 Yannick Warnier
h3. WSSession.UnsubscribeCourseFromSession
565 1 Yannick Warnier
566
Unsubscribes one course from one session
567
568
h4. Input
569
570
<pre>
571
</pre>
572
573
h4. Output
574
575 4 Yannick Warnier
<pre>
576 1 Yannick Warnier
</pre>
577
578 4 Yannick Warnier
579 1 Yannick Warnier
580
h2. Chamilo <= 1.8.7: registration.soap.php
581
582 11 Yannick Warnier
The following documentation gives a complete description of the behaviour of the Chamilo Web Services. These