Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
projet
VPLPP
Commits
44b2df48
Commit
44b2df48
authored
Nov 04, 2020
by
Guillaume Huard
Browse files
push prototype
parent
52bca793
Changes
1
Hide whitespace changes
Inline
Side-by-side
push.pl
0 → 100755
View file @
44b2df48
#!/usr/bin/perl
use
strict
;
use
LWP::
UserAgent
;
use
Data::
Dumper
;
use
File::
Slurp
;
$ENV
{
PERL_LWP_SSL_VERIFY_HOSTNAME
}
=
0
;
my
$url
=
'
https://moodle.caseine.org/webservice/rest/server.php
';
my
$vplid
=
'
19435
';
my
$token
=
'
3d610600e046a8669cb39ec4798f8a56
';
my
$ua
=
LWP::
UserAgent
->
new
(
agent
=>
'
Secret
');
my
$res
=
$ua
->
post
(
$url
,
Content_Type
=>
'
form-data
',
Content
=>
[
moodlewsrestformat
=>
'
json
',
id
=>
"
$vplid
",
wstoken
=>
"
$token
",
wsfunction
=>
'
mod_vpl_set_setting
',
settingname
=>
'
name
',
settingvalue
=>
'
Essai
',
],
);
# print Dumper($res);
my
$data
=
read_file
('
./local.sh
');
my
$res
=
$ua
->
post
(
$url
,
Content_Type
=>
'
form-data
',
Content
=>
[
moodlewsrestformat
=>
'
json
',
id
=>
"
$vplid
",
wstoken
=>
"
$token
",
wsfunction
=>
'
mod_vpl_save_execution_files
',
"
files[0][name]
"
=>
'
local.sh
',
"
files[0][data]
"
=>
"
$data
",
],
);
# Classic post does not work
# my $data = read_file('./local.sh');
# my $res = $ua->post( $url,
# Content_Type => 'form-data',
# Content => [
# moodlewsrestformat => 'json',
# id => "$vplid",
# wstoken => "$token",
# wsfunction => 'mod_vpl_save_execution_files',
# "files[0]" => [ './local.sh', 'local.sh' ],
# ],
# );
print
Dumper
(
$res
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment