7
7
* Test example to user API v2.php.
8
8
*
9
9
* 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.
11
11
*/
12
12
13
13
use GuzzleHttp \Client as Client ;
@@ -61,7 +61,7 @@ function authenticate()
61
61
*
62
62
* @return int
63
63
*/
64
- function addUsersToSession ($ apiKey )
64
+ function addCoursesToSession ($ apiKey )
65
65
{
66
66
global $ webserviceURL ;
67
67
global $ webserviceUsername ;
@@ -73,13 +73,13 @@ function addUsersToSession($apiKey)
73
73
'v2.php ' ,
74
74
[
75
75
'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
78
78
'username ' => $ webserviceUsername ,
79
79
'api_key ' => $ apiKey ,
80
- // data for users and session
80
+ // data of courses and session
81
81
'id_session ' => 1 ,
82
- 'list_users ' => [
82
+ 'list_courses ' => [
83
83
'5 ' ,
84
84
'6 ' ,
85
85
'7 ' ,
@@ -95,15 +95,15 @@ function addUsersToSession($apiKey)
95
95
$ jsonResponse = json_decode ($ response ->getBody ()->getContents ());
96
96
97
97
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 );
99
99
}
100
100
101
101
return $ jsonResponse ->data [0 ];
102
102
}
103
103
104
104
$ apiKey = authenticate ();
105
105
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 ' ;
109
109
}
0 commit comments