Skip to content
Permalink
Newer
Older
100755 59 lines (46 sloc) 1.68 KB
Oct 13, 2017
1
#!/usr/bin/perl -w
2
#
3
# canvas_test_user.pl, DESCRIPTION
4
#
5
# Copyright (C) 2017 Tom Jordan
6
#
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU General Public License
9
# as published by the Free Software Foundation; either version 2
10
# of the License, or (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# $Id:$
18
# Tom Jordan <tom.jordan@wisc.edu>
19
20
use vars qw/$VERSION $FILE/;
21
($VERSION) = q$Revision: 1.1 $ =~ /([\d.]+)/;
22
($FILE) = q$RCSfile: canvas_test_user.pl,v $ =~ /^[^:]+: ([^\$]+),v $/;
23
24
use strict;
25
use REST::Client;
26
use JSON;
27
use Data::Dumper;
28
29
my $canvas_url = "https://tier.instructure.com";
30
my $canvas_token = "10675~b1IIAPh31TCIBMRsmEqLUL436htu5Q7CP8JPMhRncRpKVh9uWYIDxbkCNWN7vSKD";
31
my $header;
32
33
$header->{'Authorization'} = "Bearer: $canvas_token";
34
$header->{'Content-type'} = "application/json";
35
36
my $client = REST::Client->new({
37
host => $canvas_url,
38
timeout => 10
39
});
40
41
# disable certificate checking
42
$client->getUseragent()->ssl_opts(verify_hostname => 0);
43
$client->getUseragent()->ssl_opts(SSL_verify_mode => "SSL_VERIFY_NONE");
44
45
my $course;
46
$course->{course}->{name} = 'Test Course1';
47
48
my $json_course = to_json($course);
49
50
print "About to call...\n";
51
$client->POST("/api/v1/accounts/1/courses?access_token=$canvas_token",$json_course,$header);
52
print "after call...\n";
53
54
print Dumper $client->responseContent();
55
56
my $response = from_json($client->responseContent());
57
58
print Dumper $response;
59
You can’t perform that action at this time.