下面是一个端到端的提交一个的例子ExtractAAMVAID请求使用Perl编程语言:

#简单的脚本,过程结果ExtractAAMVAID LEADTOOLS云服务请求。#为了运行此脚本,以下更改需要补充道:# 1)把你的应用程序ID在$ appId变量。# 2)把你的应用程序的密码密码变量#美元的脚本将执行下列操作顺序:# 1)执行ExtractAAMVAID LEADTOOLS云服务请求。一个成功的请求将返回一个惟一的标识符。# 2)我们将使用GUID查询服务,如果文件完成处理,身体将包含所有#请求数据。# 3)我们将返回的json数据,解析它,显示返回的所有信息。# # #此脚本使用了以下Perl库:# 1)HTTP消息- http://search.cpan.org/ oalders / HTTP消息- 6.15 / # 2)libwww-perl http://search.cpan.org/ oalders / libwww - Perl 6.33 / # 3) JSON-Parse - http://search.cpan.org/ bkb / json -解析- 0.55 / # 4)Try-Tiny - http://search.cpan.org/醚/尝试-小- 0.30 /使用基本的HTTP:消息;使用HTTP::要求::普遍;使用LWP:: UserAgent ();使用JSON::解析:所有的; use Try::Tiny; require HTTP::Request; require HTTP::Headers; my $servicesUrl = "https://azure.leadtools.com/api/"; #The first page in the file to mark for processing my $firstPage = 1; #Sending a value of -1 will indicate to the services that the rest of the pages in the file should be processed. my $lastPage = -1; my $appId = 'Replace with Application ID'; my $password = 'Replace with Application Password'; my $servicesUrl = "http://552da7f3710a45a69b374a1daabe818c.cloudapp.net/api/"; my $appId = 'unittestid'; my $password = 'A_K|}y-.P8*Uw7iP2S.KzqmL'; #If uploading via a URL, the Content_length needs to be set to 0. #If you are passing a file as multi-part content, the Content_Length does not need to be predefined. my $headers = HTTP::Headers->new( Content_Length => 0 ); $headers->authorization_basic($appId, $password); #The User Agent to be used when making requests my $ua = LWP::UserAgent->new; #We will be uploading the file via a URL. Files can also be passed by adding a PostFile to the request. Only 1 file will be accepted per request. #The services will use the following priority when determining what a request is trying to do GUID > URL > Request Body Content my $fileURL = 'http://demo.leadtools.com/images/cloud_samples/aamva_sample.png'; my $recognitionUrl = $servicesUrl . 'Recognition/ExtractAAMVAID?firstPage=' . $firstPage . '&lastPage=' . $lastPage . '&fileurl=' . $fileURL; my $request = POST $recognitionUrl, Content =>[]; #If uploading a file as multi-part content: #my $recognitionUrl = $servicesUrl . 'Recognition/ExtractAAMVAID?firstPage=' . $firstPage . '&lastPage=' . $lastPage; #my $request = POST $recognitionUrl, # Content_Type => 'form-data', # Content=>[ # FILE => [ "path/to/input/file" ] # ]; $request->authorization_basic($appId, $password); my $response = $ua->request($request); if(!$response->is_success){ print STDERR $response->status_line, "\n"; exit; } my $guid = $response->decoded_content; print("Unique ID returned by the services: " . $guid . "\n"); my $queryUrl = $servicesUrl . 'Query?id=' . $guid; while(true){ $request = HTTP::Request->new(POST => $queryUrl, $headers); $response = $ua->request($request); $returnedData = parse_json($response->decoded_content); if($returnedData->{'FileStatus'} != 100 && $returnedData->{'FileStatus'} != 123){ last; } sleep(5); } print("File finished processing with file status: " . $returnedData->{'FileStatus'} . "\n"); try{ # The file did not process successfully. Refer to our documentation for the full list of File Statuses and their associated meanings. if($returnedData->{'FileStatus'} != 200){ exit; } print("Results: \n"); $parsedResponse = $returnedData->{'RequestData'}; foreach my $serviceResults (@@$parsedResponse){ print "Service Type: " . $serviceResults->{'ServiceType'} . "\n"; print "Recognition Type: ". $serviceResults->{'RecognitionType'} . "\n"; my @@data = @@{$serviceResults->{'data'}}; foreach my $ammvaObj (@@data){ for $role (keys %$ammvaObj){ print "$role=$ammvaObj->{$role} \n"; } } } }catch{ print "Failed to parse JSON: " .

Perl ExtractAAMVAID教程

下面是一个端到端的提交一个的例子ExtractAAMVAID请求使用Perl编程语言:

;}