Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: HTTP POST

by gwhite (Friar)
on Mar 10, 2008 at 19:09 UTC ( #673317=note: print w/ replies, xml ) Need Help??


in reply to Re^2: HTTP POST
in thread HTTP POST

A post is not going to write to a file, a post sends data to a program that then does something with it.

what it sounds like you need to do is write a Perl program on your server, that will accept the data, then write it to your .txt file.

g_White


Comment on Re^3: HTTP POST
Re^4: HTTP POST
by kansaschuck (Sexton) on Mar 14, 2008 at 17:24 UTC
    Thanks Monks, I think I got it. An HTTP POST sends data to a program on the other end (POST and EXECUTE). In my case I had PHP take the hand off. So in PHP-land the HTTP POST shows up as an Array of values delivered in $_POST. The PHP program takes it from there (array of passed values) and if coded it can write to a file or anything php can do. My Perl send off below:

    my $req = new HTTP::Request 'POST','http://foobar.com/stuff/post.php';
    $req->content_type('application/x-www-form-urlencoded');

    my $text = "rambling text message here for future use, Dave can hear me. ";
    my $user = "yourusernamehere";
    my $pass = "yourpasswordhere";
    my $number = "44.55";

    $req->content("user=" . $user . "&pass=" . $pass . "&text=" . $text . "&number=" . $number);
    my $res = $ua->request($req);
    print $res->as_string;


    So basically I had two misconceptions:
    1) that POST could just write directly to a remote .txt file.
    2) something else that escaped me at first is that echo and print statements at the server within the remote (php) program are returned to sender. I had the view that POST was sort of one way comms. But it's more POST-EXECUTE-REPLY.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://673317]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2014-04-24 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (565 votes), past polls