using post method

H

hash

Hello All,
I am trying to use the post method in perl to fill a form. The form
is actually for sending an instant message to a cell phone, i
would like to do this automatically without going to the site.
I read the source file for the web page and extracted the text field
names, area=area code, num1=first 3 digit, num2=4 digit, text=the text
to send, but my phone doesn't get the message. Has anyone done this
before and can all forms that are fillable in a web page can be filled
using post method?

thanks in advance for your help, the script i am using is given below.

web site
---------
http://www.rogers.com/english/wireless/sendpcs.html

script
-------
use LWP::UserAgent;
$ua = LWP::UserAgent->new;

my $req = HTTP::Request->new(POST =>
'http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new');
$req->content_type('application/x-www-form-urlencoded');
$req->content('area=xxx&num1=xxx&num2=xxxx&text=xx');

my $res = $ua->request($req);
print $res->as_string;

exit;
 
G

Gregory Toomey

hash said:
Hello All,
I am trying to use the post method in perl to fill a form. The form
is actually for sending an instant message to a cell phone, i
would like to do this automatically without going to the site.
I read the source file for the web page and extracted the text field
names, area=area code, num1=first 3 digit, num2=4 digit, text=the text
to send, but my phone doesn't get the message. Has anyone done this
before and can all forms that are fillable in a web page can be filled
using post method?

thanks in advance for your help, the script i am using is given below.

Are you saying this works or does not? Have you tried?

Using the KISS principle I would try:

#!/usr/bin/perl
use LWP::Simple;

getprint('http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new?area=xxx&num1
=xxx&num2=xxxx&text=xx');

gtoomey
 
T

Tad McClellan

hash said:
I am trying to use the post method in perl to fill a form.
but my phone doesn't get the message.


You need to get at least a little bit of debugging information
before you can do any debugging...

use LWP::UserAgent;


use LWP::Debug qw(+);

my $res = $ua->request($req);


die 'ERROR: ', $res->status_line(), "\n", $res->error_as_HTML()
unless $res->is_success;
 
H

hash

hi Tad,

when tried running perl myscript with debugging on, i got the
following:
what does "Not proxied" means?

LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: POST
http://216.129.53.44:8080/cgi-bin/send_sm_rogers.new
LWP::UserAgent::_need_proxy: Not proxied
LWP::protocol::http::request: ()
LWP::protocol::collect: read 862 bytes
LWP::protocol::collect: read 939 bytes
LWP::UserAgent::request: Simple response: OK

--------------------------------------------
 
H

hash

hi greg,

I also tried using the get method, this is what i got:

"Bad configuration, the query string is not from FORM"

I thought, the site somehow knows that I didn't actually fill out the
form on the web page they specify, could this be?
thanks,
 
D

Dave Millen

hi greg,

I also tried using the get method, this is what i got:

"Bad configuration, the query string is not from FORM"

I thought, the site somehow knows that I didn't actually fill out the
form on the web page they specify, could this be?

<snip>

The form handler will be checking the HTTP_REFERER value and rejecting
anything that doesn't come from the expected page.

Regards,
Dave
 
E

Eric Schwartz

Dave Millen said:
The form handler will be checking the HTTP_REFERER value and rejecting
anything that doesn't come from the expected page.

s/come from/claim to $&/

-=Eric
 
H

hash

Dave Millen said:
<snip>

The form handler will be checking the HTTP_REFERER value and rejecting
anything that doesn't come from the expected page.

So is this mean that it is impossible to use perl to post to this site,
or is there a way to make it think that it comes from the form?
 
U

Uri Guttman

ES> s/come from/claim to $&/

don't use $& as it will slow down all the other regexes in your usenet
posts.

:)

uri
 
T

Tad McClellan

hash said:
what does the above line mean?


---------------------------------
#!/usr/bin/perl
use strict;
use warnings;

$_ = "rejecting anything that doesn't come from the expected page\n";
print "before: $_";

s/come from/claim to $&/;
print "after: $_";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,121
Messages
2,570,712
Members
47,283
Latest member
hopkins1988

Latest Threads

Top