Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#---------------------------------------------------------------------
# WebMallRemoteFunc
#---------------------------------------------------------------------
# Perform some webmall function on the 1webstreet.net server.
# Since this is a different server, we use an http request to call
# a cgi program remotely and parse the returned "web page".
#
# Parameters: Function, webmall name
#
# Returns: Ref to hash containing returned data (parameters passed,
# error message, return code.
#---------------------------------------------------------------------
sub WebMallRemoteFunc {
local($func, $webmall, $newmall) = @_;
%Ret = ();
my $domain = "[URL unfurl="true"]http://www.xxx.com";[/URL]
my $cgidir = "/cgi-local";
my $cgipgm = "WebMallRemoteFuncs.pl";
my %form = ();
if ( lc($func) ne "rename" ) {
%form = ( FUNC => $func, WebMall => $webmall );
} else {
%form = ( FUNC => $func, WebMall => $webmall, NewMall => $newmall );
}
use URI::URL;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $tmpurl = url("http:");
$tmpurl->query_form(%form);
my $req = new HTTP::Request 'POST', "$domain$cgidir/$cgipgm";
$req->content_type('application/x-[URL unfurl="true"]www-form-urlencoded');[/URL]
$req->content($tmpurl->equery);
print "<b>WebMallRemoteFunc: Content: </b>" . $tmpurl->equery . "<br><br>" if $debug;
my $res = $ua->request($req);
if ( $res->is_success ) {
$returnData = $res->as_string;
} else {
$Ret{'Error'} = "HTTP error: " . $res->code . " " . $res->message;
$Ret{'Return'} = 0;
print "<b>WebMallRemoteFunc: Error: </b>" . $Ret{'Error'} . "<br><br>" if $debug;
return \%Ret;
}
print "<b>WebMallRemoteFunc: Returned Data: </b><br><pre>$returnData</pre><br><br>" if $debug;
# Parse the data returned in the "web page" and return it.
$PassedHeader = 0;
@returnData = split('\n', $returnData);
for (@returnData) {
$PassedHeader = 1 if /\A\Z/;
next unless $PassedHeader;
$Ret{$1} = $2 if /\A(.+):\s+(.+)\Z/;
}
if ( $debug ) {
print "<b>WebMallRemoteFunc: Returning hash: </b><br><pre>";
while ( ($key,$val) = each %Ret ) {
print "$key => $val\n";
}
print "</pre><br>";
}
return \%Ret;
} # WebMallRemoteFunc