powerhouse has asked for the wisdom of the Perl Monks concerning the following question:
123,02928,06/28/2004,9.50
124,02893,06/28/2004,20.00
That is in this order....
Invoice Number, Store Number, Date, Amount
This is not working, it is erroring out at my "cannot login" exit point.my $_invoices = param("invoices"); # Get the value of the text +area if ($_invoices && $_invoices =~ /\015\012/) { $_split_val = "\015\012"; } elsif ($_invoices && $_invoices =~ /\r\n/) { $_split_val = "\r\n"; } use HTTP::Cookies; $cookie_jar = HTTP::Cookies->new( 'file' => "/home/first/cook/lwp_cookies.dat", 'autosave' => 1, ); my $_post_url = 'http://www.eb2b.net/E2B_UMLogOn.process'; my $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); my $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content("IWPEProcessFlow.submitted.sequenceID=&logonUser +name=myhiddenusername&logonPassword=myhidden_password&Logon=Login&hMs +gUserNotFound=User with this name was not found.&hMsgInvalidPassword= +Logon not valid.&fromHomePage=default_B2B.htm"); $req->referrer("http://www.eb2b.net/"); # Spoof their website. +.. my $res = $ua->request($req); if (!$res->is_success) { $_message = get_error_table("I could not login to the eb2b +.net website.... please check what is up with that..."); $in{view} = "start_form"; batch_features(); return; } my $_invoices_started = 0; my $_invoices_ended = 0; while($_invoices ne "") { $_invoices_started++; (my $_line_val, $_invoices) = split /$_split_val/, $_invoi +ces, 2; # Split $_invoices and shorten by $_line_val.... next if !$_line_val; # Does not contain anything go to the + next line.... ($_inv_num,$_store_number,$_inv_date,$_amount) = split /\, +/, $_line_val, 4; # Reset Page.... $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $response = $ua->get('https://www.eb2b.net/E2B_OMInvoiceCr +editMgmt.process?RestartFlow=t'); # Start Template.... $_post_url = 'http://www.eb2b.net/E2B_SelectTemplate.proce +ss?restartFlow=t'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content("SelectTemplate=Use Template >"); $req->referrer("https://www.eb2b.net/E2B_OMInvoiceCreditMg +mt.process?RestartFlow=t"); $res = $ua->request($req); # Create Invoice from Template... $_post_url = 'http://www.eb2b.net/E2B_OMInvoiceCreditMgmt. +process?restartFlow=t&FromTemplate=t&Template_Id=522'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content("Relationship_Index=0&CInvoice=Create Invoic +e"); $req->referrer("https://www.eb2b.net/E2B_SelectTemplate.pr +ocess?restartFlow=t"); $res = $ua->request($req); # Post Invoice... $_post_url = 'http://www.eb2b.net/E2B_OMInvoiceCreditMgmt. +process'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); # Create content into form.... $_content = "E2B_OMInvoiceCreditForm.Purchase_Order_Number +=&Location_Number=" . $_store_number . "&VendorRelationshipIndex=0&E2 +B_OMInvoiceCreditForm.Invoice_Number=" . $_inv_num . "&Purchase_Order +_Date=&E2B_OMInvoiceCreditForm.Bill_Of_Lading_Number=&Invoice_Date=" +. $_inv_date . "&E2B_OMInvoiceCreditForm.Trailer_Number=&Ship_Date=" +. $_inv_date . "&E2B_OMInvoiceCreditForm.Fob_Code=CC&Total_Invoice_Ca +rtons=1&Carrier_Code=ZZZZ&E2B_OMInvoiceCreditForm.Sales_Division_Numb +er=6131195061&E2B_OMInvoiceCreditForm.Net_Invoice_Total=0&E2B_OMInvoi +ceCreditForm.EditPageMarker=&E2B_OMInvoiceCreditForm.LineItemVector[0 +].Line_Number=1&E2B_OMInvoiceCreditForm.LineItemVector[0].Vendor_Item +_Number=DD&E2B_OMInvoiceCreditForm.LineItemVector[0].Customer_Item_Nu +mber=&E2B_OMInvoiceCreditForm.LineItemVector[0].Upc_Code=&E2B_OMInvoi +ceCreditForm.LineItemVector[0].UPC_NDC_Indicator= &E2B_OMInvoiceCredi +tForm.LineItemVector[0].Item_Description=Maintenance&E2B_OMInvoiceCre +ditForm.LineItemVector[0].Quantity_Shipped=1&E2B_OMInvoiceCreditForm. +LineItemVector[0].Unit_Of_Measure=EA&E2B_OMInvoiceCreditForm.LineItem +Vector[0].Pack_Size=1&E2B_OMInvoiceCreditForm.LineItemVector[0].Unit_ +Price=" . $_amount . "&rcDirection=&selectedLine=&IWPEProcessFlow.sub +mitted.sequenceID=/E2B_OMInvoiceCreditMgmt.process|runProcessE2B_OMMa +nualInvoiceCredit|expandE2B_OMManualInvoiceCredit&Invoice_Complete_Fl +ag=0&E2B_OMInvoiceCreditTermsAllowancesDirection="; $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content($_content); $req->referrer("https://www.eb2b.net/E2B_OMInvoiceCreditMg +mt.process?restartFlow=t&FromTemplate=t&Template_Id=522"); $res = $ua->request($req); # Ok, now take the invoice just created and add the "a +ccounting code" then send it to ekerdx $_post_url = 'http://www.eb2b.net/E2B_OMInvoiceCreditMgmt. +process'; $ua = LWP::UserAgent->new; $ua->cookie_jar($cookie_jar); # Create content into form.... $_content = "E2B_OMInvoiceCreditTermsAllowancesDirection=& +selectedAllowanceCollection=&selectedLine=&IWPEProcessFlow.submitted. +sequenceID=/E2B_OMInvoiceCreditMgmt.process|runProcessE2B_OMInvoiceCr +editTermsAllowances|expandE2B_OMInvoiceCreditTermsAllowances&Bus_Unit +=00&Acct=664600&Cost_Dep_No=0000&RowSkip=&RowChunk=&TabChoice=&search +By=&E2B_OMInvoiceCreditTermsAllowancesDirection=Confirm"; $req = HTTP::Request->new(POST => "$_post_url"); $req->content_type('application/x-www-form-urlencoded'); $req->content($_content); $req->referrer("https://www.eb2b.net/E2B_OMInvoiceCreditMg +mt.process"); $res = $ua->request($req); # All Done.... $_invoices_ended++; } $_page_content .= qq~Ok, I have started $_invoices_started inv +oices and finished $_invoices_ended invoices!<br> <br>~;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remote Login and Form Posting
by Corion (Patriarch) on Jun 30, 2004 at 07:59 UTC | |
by powerhouse (Friar) on Jul 01, 2004 at 07:04 UTC | |
by Corion (Patriarch) on Jul 01, 2004 at 07:56 UTC |