Thread

Posted on Thu Feb 17 10:08:40 2005 by agomezre54
- example with ghttp -
Hello, I would like to know an example of a typical real code for sending a message with this library, and configuring typical things. Thank you,
Direct Responses: 6133 | Write a response
Posted on Thu Sep 27 20:22:50 2007 by dstory in response to 130
Re: - example with ghttp -
use strict; use HTTP::GHTTP qw/:methods/; # # Post (data) to the specified (url). sub post_data { my ($url, $data) = @_; my $err = 0; my $r = HTTP::GHTTP->new($url, Connection => 'close'); if ($r) { $r->set_type(METHOD_POST); $r->set_body($data); $r->prepare(); $r->process_request(); my ($num, $msg) = $r->get_status(); if ($num != 200) { $err = 1; print("Post failed with: $num $msg\n"); } else { print("Posted\n"); } } else { $err = 2; print("Post failed\n"); } return $err; }
Write a response