Kaynağa Gözat

functions to call api

nas 2 yıl önce
ebeveyn
işleme
a68bc7f8c0
1 değiştirilmiş dosya ile 16 ekleme ve 9 silme
  1. 16
    9
      test/test.pl

+ 16
- 9
test/test.pl Dosyayı Görüntüle

@@ -14,15 +14,22 @@ print "Host : $config{Authentification}{Path}\n";
14 14
 print "Protocol : $config{Authentification}{Username}\n";
15 15
 
16 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 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 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…
İptal
Kaydet