From 37acca4dd252cf1ab50435ae014072a86550e8c6 Mon Sep 17 00:00:00 2001 From: pigui Date: Fri, 30 Jan 2009 11:48:50 +0000 Subject: [PATCH] Adding testclients for create_group and add_groupmember MDL-13142 MDL-13139 --- webservice/rest/testclient/addgroupmember.php | 69 ++++++++++++++++++ webservice/rest/testclient/creategroup.php | 70 +++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 webservice/rest/testclient/addgroupmember.php create mode 100644 webservice/rest/testclient/creategroup.php diff --git a/webservice/rest/testclient/addgroupmember.php b/webservice/rest/testclient/addgroupmember.php new file mode 100644 index 0000000000..e769545cd0 --- /dev/null +++ b/webservice/rest/testclient/addgroupmember.php @@ -0,0 +1,69 @@ + + +
+ + + + +
Group id:
User id:
+
+ +serverurl.'/group/tmp_add_groupmember'); + + + //we are asking for a token + $connectiondata['username'] = 'wsuser'; + $connectiondata['password'] = 'wspassword'; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); + $token = curl_exec($ch); + + $data['token'] = $token; + $data['groupid'] = $groupid; + $data['userid'] = $userid; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_add_groupmember'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); + $out = curl_exec($ch); + + $res = basicxml_xml_to_object($out); + + show_object($res->result); + + show_xml ($out); +} else { + echo "

Fill the form first

"; +} + +end_interface(); + +?> diff --git a/webservice/rest/testclient/creategroup.php b/webservice/rest/testclient/creategroup.php new file mode 100644 index 0000000000..c02ef42598 --- /dev/null +++ b/webservice/rest/testclient/creategroup.php @@ -0,0 +1,70 @@ + + +
+ + + + +
Group name:
Course id:
+
+ +serverurl.'/group/tmp_create_group'); + + + //we are asking for a token + $connectiondata['username'] = 'wsuser'; + $connectiondata['password'] = 'wspassword'; + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); + $token = curl_exec($ch); + + $data['token'] = $token; + $data['groupname'] = $groupname; + $data['courseid'] = $courseid; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_create_group'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); + $out = curl_exec($ch); + + $res = basicxml_xml_to_object($out); + + show_object($res->groupid); + + show_xml ($out); +} else { + echo "

Fill the form first

"; +} + +end_interface(); + +?> -- 2.39.5