瀏覽代碼

functions to call api

nas 2 年之前
父節點
當前提交
a68bc7f8c0
共有 1 個文件被更改,包括 16 次插入9 次删除
  1. 16
    9
      test/test.pl

+ 16
- 9
test/test.pl 查看文件

@@ -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…
取消
儲存