#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    0
    Rep Power
    0
    I have 2 sites (A and B), and I must call a script on site B from site A, get the results on A, and display them.

    I wrote a script (on site A) that I call with a POST method from a form on a page on the same site.
    This script receives the arguments, calls the script on site B, receives the answer, and displays it.
    The call of the script on B works, but the arguments sent to it are never received.
    So it's useless!!

    Would somebody see what I did wrong on passing the arguments?

    The script is as follows:

    #!/usr/bin/perl
    #######################################################
    # remote.cgi : calling remote script
    #######################################################

    require HTTP::Request;
    require LWP::UserAgent;
    require HTTP::Headers;

    &parsedata;
    $url = $form{'url'};
    $method = $form{'method'};
    if ($method eq '') { $method = 'POST'; }
    my $ua = LWP::UserAgent->new;
    $h = new HTTP::Headers;
    foreach $key (keys %form)
    {
    if ($key ne 'url' && $key ne 'method')
    {
    $h->push_header($key => $form{$key});
    }
    }
    my $request = HTTP::Request->new($method => $url, $h);
    my $response = $ua->request($request);
    $rc = ($response->is_success) ?
    $response->content:
    $response->error_as_HTML;
    print "Content-type: text/htmlnn$rc";

    sub parsedata
    {
    my $buffer = "";
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    my @pairs=split(/&/,$buffer);
    foreach my $pair (@pairs)
    {
    my ($name,$value) = split(/=/,$pair);
    $value =~ s/+/ /g;
    $value =~ s/~!/ ~!/g;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/[]//g;
    push (@data,$name);
    push (@data, $value);
    }
    %form=@data;
    %form;
    }
    ###### end of script ###########


    Thanks for your help!


  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Start here -> http://www.devshed.com/Talk/Forums/F...ML/000387.html and check out this simple example.

IMN logo majestic logo threadwatch logo seochat tools logo