Hi, my question is,
I need to invoke a PHP script that sits outside of the intranet ( an external server ) from my local machine.
I've tried using fopen but it only support intranet direction. So, I'm asking if there's any other ways, except fopen, that I can call a script automatically ?
Here's the script that I've adopted:
<?
//filename: posttohost.php
function PostToHost($host, $path, $data)
{
$fp = fsockopen($host, 80);
printf("Open!\n");
fputs($fp, "POST $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, "$data");
printf("Sent!\n");
while(!feof($fp))
{
$res .= fgets($fp, 128);
}
printf("Done!\n");
fclose($fp);
return $res;
}
// Test the function
$query_string = "login=bbbear&var=abctesting";
printf("Go!\n");
// Change this line before you test it on your server
print $x = PostToHost("192.xxx.xxx.xxx", "/path/to/project/test.php", $query_string);
?>
What I'm doing at the above is I'm trying to run a script named 'test.php' that sits on another server. However this function only support internal host. Anything outside proxy, that will not work. Any idea of how to get things around ?
Thank you very much.
Regards,