ASP help for PHP me
Author
Discussion

KITT

Original Poster:

5,345 posts

271 months

Monday 8th August 2005
quotequote all
Right, I'm familar with PHP and have been asked to convert a load of my PHP code into ASP. Specifically VB ASP.

The bit I'm stuggling with is as follows:

php said:
function httpPost($host, $path, $referer, $data) {

$fp = fsockopen($host, 80 );
fputs($fp, "POST ".$path." HTTP/1.0 " );
fputs($fp, "Host: ".$host." " );
fputs($fp, "Referer: ".$referer." " );
fputs($fp, "Content-type: application/x-www-form-urlencoded " );
fputs($fp, "Content-length: ".strlen($data)." " );
fputs($fp, " " );
fputs($fp, $data." " );
fputs($fp, " " );

$tmp_headers = "";
while ($str = trim(fgets($fp, 4096)))
$tmp_headers .= $str." ";

$tmp_body = "";

do {
$data = fread($fp, 4096);
if (strlen($data) == 0) {
break;
}
$tmp_body .= $data;
} while(true);

fclose($fp);
return $tmp_body;
}

This function basically allows me to call another page on a different server. This is so I can parse the return before I display the result to the user. Is there a way of doing this in ASP?

cheers

>> Edited by KITT on Monday 8th August 14:56

Don

28,378 posts

314 months

Monday 8th August 2005
quotequote all
I think to do that in ASP you'll need to find a library that does the functions you need. I think the Microsoft Internet Controls COM Object should do the trick.

Your code will be something like

dim htmlObj, szRet, szPage

Set htmlObj = Server.CreateObject( "InetCtls.Inet" )

szPage = "http://theotherserver/thepage.asp"

szRet = htmlObj.OpenURL(szPage)

'now parse szRet

>> Edited by Don on Monday 8th August 16:56