Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # 20170328 - mflores - Prueba de subir fichero Haberes.xls.
- use strict;
- use warnings;
- # Global Vars.
- my $debug = 0;
- # OAuth Vars.
- my $client_id = 2;
- my $client_secret = "zvzY7SugOyUpUq61oug7AZTHmIKekuGikaQ62ss5";
- # User Vars.
- my $username = 'socio@example.com';
- my $password = "secret";
- my $auth_uri = "https://api.test.sistema.unionportuaria.cl/oauth/token";
- # Import Vars.
- my $file = "/tmp/Haberes.xls";
- my $import_uri = "https://api.test.sistema.unionportuaria.cl/api/plantilla/testImport";
- my $resp1 = `curl -s 1 -F "grant_type=password" -F "client_id=$client_id" -F "client_secret=$client_secret" -F "username=$username" -F "password=$password" $auth_uri`;
- print "DEBUG: $resp1 \n" if $debug;
- my ($token_type, $expires_in, $access_token) = split ",", $resp1;
- print "DEBUG: $access_token \n" if $debug;
- my ($name, $string) = split ":", $access_token;
- print "DEBUG: $string \n" if $debug;
- my $token = substr( $string, 1, (length($string) - 2) );
- print "DEBUG: $token \n" if $debug;
- system("curl -H \"Authorization: Bearer $token\" -F archivo=@\"$file\" $import_uri");
- # print ("curl -H \"Authorization: Bearer $token\" -F archivo=@\"$file\" $import_uri");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement