473,695 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

LWP::UserAgent to POST and redirect browser at the same time

Hello - I am new to Perl, so sorry if this is a silly / ultra easy
question.

I am using LWP::UserAgent to POST a HTTP message to another website, and it
works great.

However, I can't figure out how to redirect the user to a script at the same
time as the post. (i.e. emulate sumbitting a form and being sent to a page.

$org_response = $res->as_string; this gives me the page as a string, but
I want to send the user there

http://www.perldoc.com/perl5.6/lib/LWP/UserAgent.html does not help
:-(

Thanks!
Jul 19 '05 #1
9 11804
La Jesus wrote:
I can't figure out how to redirect the user to a script at the same
time as the post. (i.e. emulate sumbitting a form and being sent
to a page.

$org_response = $res->as_string; this gives me the page as a
string, but I want to send the user there


print "Location: $org_response\n \n";

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2
Gunnar Hjalmarsson wrote:
La Jesus wrote:
I can't figure out how to redirect the user to a script at the
same time as the post. (i.e. emulate sumbitting a form and being
sent to a page.

$org_response = $res->as_string; this gives me the page as a
string, but I want to send the user there


print "Location: $org_response\n \n";


Sorry, I was too quick with clicking the send button. To redirect to a
certain URL, and provided that the URL is in e.g. the variable $url,
you can do:

print "Location $url\n\n";

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #3
>print "Location $url\n\n";

What I want to do is POST $url a group of vars, and redirect the user to the
site where the POST went. So it will be "as if" the user filled out a form
on a webpage, and got redirected to the site. I think (?) that if I "print
"Location ..." then it won't be linked to the POST message.

1) User hits submit on Site A
2) Form gets sent to CGI in Site B
3) User gets redirected to Site C, as if they submitted there in Site 1

THANKS for your time!

--
while ( ($key, $value) = each(%aec) ) {$aec_post=$aec _post."$key=$va lue\&";}
$ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(POST => $url);
$req->content_type(' application/x-www-form-urlencoded');
$req->content($aec_p ost);
my $res = $ua->request($req );
Jul 19 '05 #4
3) User gets redirected to Site C, as if they submitted there in STEP 1, (I
meant.)


Jul 19 '05 #5
La Jesus wrote:
print "Location $url\n\n";


What I want to do is POST $url a group of vars, and redirect the
user to the site where the POST went. So it will be "as if" the
user filled out a form on a webpage, and got redirected to the
site. I think (?) that if I "print "Location ..." then it won't
be linked to the POST message.

1) User hits submit on Site A
2) Form gets sent to CGI in Site B
3) User gets redirected to Site C, as if they submitted there in
step 1


What's the reason why you don't submit the data via a form instead of
using LWP::UserAgent?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #6
I am making a "middleware " system for a shopping cart. I take what-ever the
shopping cart sends, remap variable names, add some others, and send it to
the payment processors. This is instead of changing everything in the
cart - it's much easier.

So, the shopping cart sends to my script, I do some changes, and send it the
payment processor. However, the user must log into their account, like
PayPal. So, I need to "post" and send the user there
"Gunnar Hjalmarsson" <no*****@gunnar .cc> wrote in message
news:AY******** ***********@new sb.telia.net...
La Jesus wrote:
print "Location $url\n\n";


What I want to do is POST $url a group of vars, and redirect the
user to the site where the POST went. So it will be "as if" the
user filled out a form on a webpage, and got redirected to the
site. I think (?) that if I "print "Location ..." then it won't
be linked to the POST message.

1) User hits submit on Site A
2) Form gets sent to CGI in Site B
3) User gets redirected to Site C, as if they submitted there in
step 1


What's the reason why you don't submit the data via a form instead of
using LWP::UserAgent?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #7
La Jesus wrote:
Gunnar Hjalmarsson wrote:
What's the reason why you don't submit the data via a form
instead of using LWP::UserAgent?


I am making a "middleware " system for a shopping cart. I take
what-ever the shopping cart sends, remap variable names, add some
others, and send it to the payment processors. This is instead of
changing everything in the cart - it's much easier.

So, the shopping cart sends to my script, I do some changes, and
send it the payment processor. However, the user must log into
their account, like PayPal. So, I need to "post" and send the user
there


Okay, I think I get the picture, but I have to admit that I'm not able
to provide a solution. In some way, if possible, you want the HTTP
response to go to the browser instead of the script from which the
request was actually sent...

If you didn't know it, this newsgroup is defunct, and it's basically
not a good idea to ask questions here. I believe that the most
appropriate Usenet group for your problem is

comp.infosystem s.www.authoring.cgi (ciwac)

For more general Perl problems (i.e. not this particular problem) you
should better use

comp.lang.perl. misc

in the future.

I would recommend that you ask for help at ciwac. If you haven't
posted there before, don't forget to approve your post:
http://www.thinkspot.net/ciwac/howtopost.html

Good luck!

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #8
Thanks! I posted it there. I tried to approve it, but I get "sender not
found". I followed all the directions. However, I see it there (from
edgreen - a temp e-mail I used to avoid spam) Do you see it as well?
"Gunnar Hjalmarsson" <no*****@gunnar .cc> wrote in message
news:nK******** ***********@new sb.telia.net...
La Jesus wrote:
Gunnar Hjalmarsson wrote:
What's the reason why you don't submit the data via a form
instead of using LWP::UserAgent?


I am making a "middleware " system for a shopping cart. I take
what-ever the shopping cart sends, remap variable names, add some
others, and send it to the payment processors. This is instead of
changing everything in the cart - it's much easier.

So, the shopping cart sends to my script, I do some changes, and
send it the payment processor. However, the user must log into
their account, like PayPal. So, I need to "post" and send the user
there


Okay, I think I get the picture, but I have to admit that I'm not able
to provide a solution. In some way, if possible, you want the HTTP
response to go to the browser instead of the script from which the
request was actually sent...

If you didn't know it, this newsgroup is defunct, and it's basically
not a good idea to ask questions here. I believe that the most
appropriate Usenet group for your problem is

comp.infosystem s.www.authoring.cgi (ciwac)

For more general Perl problems (i.e. not this particular problem) you
should better use

comp.lang.perl. misc

in the future.

I would recommend that you ask for help at ciwac. If you haven't
posted there before, don't forget to approve your post:
http://www.thinkspot.net/ciwac/howtopost.html

Good luck!

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #9
Ed Green wrote:
Thanks! I posted it there. I tried to approve it, but I get
"sender not found". I followed all the directions. However, I see
it there (from edgreen - a temp e-mail I used to avoid spam) Do
you see it as well?


No, at least it has not yet reached the newsgroup server that I'm
using for ciwac. Note that you need to approve the article from the
same address as the article was posted.

Another general Usenet advise: Don't top post when replying!
http://web.presby.edu/~nnqadmin/nnq/nquote.html

Following those advises will increase your chances to get your
questions answered.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2275
by: Chandra | last post by:
Hello gurus, I am using LWP::Useragent perl module to get a url from the www. Code snippet: #!perl -w use LWP::UserAgent; LWP::Debug::level('+'); $ua = new LWP::UserAgent || die "$!";
2
6094
by: Vinay Gupta | last post by:
Hi, In a Perl to Tcl conversion project, I am planning to use the following Tcl extensions as a replacement for some Perl libraries. My development environment is Windows. Win32::OLE --> "DDE" or "OpTcl" LWP::UserAgent, HTTP::Request --> "Scotty" Net::Telnet --> "Expect" ('spawn telnet') I have used Expect but haven't used Scotty, DDE or OpTcl before.
0
2880
by: Playker | last post by:
Hello I have a website on 2 servers. I want to make a script which checks is first server availbale (he often breaks down) and redirects to 1st or 2nd server. Script works well if an error is the 404 error, but it doesn't work if server doesn't answer (and that's what I want). Can anyone help me? This is the code: #!/usr/bin/perl ## ##
3
12017
by: suchindra | last post by:
The following is my very simple script : </script> #!/usr/bin/perl use strict; use LWP::UserAgent; my $url = "<My Web Server IP : PORT Number>"; my $browser = LWP::UserAgent->new(keep_alive => 5, timeout => 10, agent => 'unimportant',);
0
2546
by: sharif | last post by:
Anyone could help me out for n=my code ......I have written following code ,Here i m able to get and post the form successfuly..but after posting im not gettng proper response content... #!usr/bin/perl -w use strict; use LWP; use LWP::Simple; use LWP::UserAgent; use HTML::Form; use Switch; use HTTP::Cookies;
2
1477
by: haimk63 | last post by:
Hi ! I am beginner in PERL. I would like to know whether the LWP::UserAgent module? can be used in any server that supports PERL. Thanks
3
2182
by: powersakthi | last post by:
Hi All, I am using LWP::UserAgent and HTML::TreeBuilder to communicate to the below site Here is the website map: https://secure.server.com/index.htm which asks for two fields user_id user_pwd then submit button the form is submitted to https://secure.server.com/login.asp
4
4228
by: kkamath | last post by:
Hi, I use LWP::UserAgent to automate windows login process. I set the credentials using $ua->credentials("host:port","realm","id","password"); but it fetches only the current page requested. It fails for subsequent requests and pops up the windows form again to supply the credentials. I have created a cookie jar too but this doesnt help as the authentication is not sticking. Any help on this is highly appreciated. The code is as follows. ...
3
3332
by: cketcham | last post by:
All, I have the following code: use 5.010; use LWP::UserAgent; use URI::URL; use LWP::Debug qw(+); my $browser = LWP::UserAgent->new();
0
8647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9132
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9004
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8864
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8838
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4592
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2288
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1986
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.