Browse Source

functions to call api

nas 2 years ago
parent
commit
a68bc7f8c0
1 changed files with 16 additions and 9 deletions
  1. 16
    9
      test/test.pl

+ 16
- 9
test/test.pl View File

14
 print "Protocol : $config{Authentification}{Username}\n";
14
 print "Protocol : $config{Authentification}{Username}\n";
15
 
15
 
16
 local $url = "$config{Authentification}{Host}$config{Authentification}{Path}";
16
 local $url = "$config{Authentification}{Host}$config{Authentification}{Path}";
17
- 
18
-my $ua = LWP::UserAgent->new(timeout => 10);
17
+local $ua = LWP::UserAgent->new(timeout => 10);
19
 $ua->env_proxy;
18
 $ua->env_proxy;
20
- 
21
-my $response = $ua->get( $url );
22
- 
23
-if ($response->is_success) {
19
+
20
+sub rq {
21
+  my $path = (exists $_[0])? $_[0] : "";
22
+  my $response = $ua->get( "$url$path" );
23
+  print "rq $url$path\n";
24
+  if ($response->is_success) {
24
     print $response->decoded_content;
25
     print $response->decoded_content;
26
+    print "\n";
27
+  }
28
+  else {
29
+    print $response->status_line;
30
+    print "\n";
31
+  }
25
 }
32
 }
26
-else {
27
-    die $response->status_line;
28
-}
33
+
34
+rq();
35
+rq( "tokens" );

Loading…
Cancel
Save