Skip to content

Commit e630ede

Browse files
committed
Webservice: Update example WS call for add_courses_session - refs #5504
1 parent ef54cc0 commit e630ede

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

main/webservices/api/example/add_courses_session.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Test example to user API v2.php.
88
*
99
* Using Guzzle' HTTP client to call the API endpoint and make requests.
10-
* Change URL on the first lines of createUser() below to suit your needs.
10+
* Change URL on the first lines of addCoursesToSession() below to suit your needs.
1111
*/
1212

1313
use GuzzleHttp\Client as Client;
@@ -61,7 +61,7 @@ function authenticate()
6161
*
6262
* @return int
6363
*/
64-
function addUsersToSession($apiKey)
64+
function addCoursesToSession($apiKey)
6565
{
6666
global $webserviceURL;
6767
global $webserviceUsername;
@@ -73,13 +73,13 @@ function addUsersToSession($apiKey)
7373
'v2.php',
7474
[
7575
'form_params' => [
76-
// data for the user who makes the request
77-
'action' => 'add_users_session',
76+
'action' => 'add_courses_session',
77+
// data of the user who makes the request
7878
'username' => $webserviceUsername,
7979
'api_key' => $apiKey,
80-
// data for users and session
80+
// data of courses and session
8181
'id_session' => 1,
82-
'list_users' => [
82+
'list_courses' => [
8383
'5',
8484
'6',
8585
'7',
@@ -95,15 +95,15 @@ function addUsersToSession($apiKey)
9595
$jsonResponse = json_decode($response->getBody()->getContents());
9696

9797
if ($jsonResponse->error) {
98-
throw new Exception('Users not assigned to session because : '.$jsonResponse->message);
98+
throw new Exception('Courses not assigned to session because : '.$jsonResponse->message);
9999
}
100100

101101
return $jsonResponse->data[0];
102102
}
103103

104104
$apiKey = authenticate();
105105

106-
//adding users with id 5, 6, 7 to session with id 1
107-
if (addUsersToSession($apiKey)) {
108-
echo 'Users successfully added';
106+
//adding courses with id 5, 6, 7 to session with id 1
107+
if (addCoursesToSession($apiKey)) {
108+
echo 'Courses successfully added';
109109
}

0 commit comments

Comments
 (0)