View Full Version : hit another page
esthera
05-09-2006, 05:50 PM
how can I hit another page in my script in php.
I know in asp I would do as follows:
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
tresponse= xmlhttp.responseText
set xmlhttp = nothing
http://us3.php.net/manual/en/function.fsockopen.php
http://us3.php.net/manual/en/function.file-get-contents.php
can only do file_get_contents if the fopen_wrappers have been enabled
esthera
05-10-2006, 04:38 PM
so i tried
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
with my url and the out as my site and string and I get the following message :
The operation completed successfully. (0)
what does this mean? It doesn't seem to have made the hit.
try file_get_contents instead (note: file_get_contents isn't as portable since allow_url_fopen has to be set in the php.ini in current versions of php..), or try fopen:
http://us2.php.net/fopen
esthera
05-10-2006, 05:46 PM
thanks for your reply..
now i get the error
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
here's teh code:
$myrequest="http://www.myserver.com/process.asp?name=test&username=testing";
$handle = fopen("$myrequest", "r");
esthera
05-10-2006, 05:49 PM
i want to add to teh above that is is making the hit now just also returning an error -- i don't need to retrieve anything -- how can I just get rid of the error?
read here:
http://calibro.candyham.com/2006/03/08/cgi-error-the-specified-cgi-application-misbehaved/
then here for more details:
http://bugs.php.net/bug.php?id=25863
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.