PHPPost\ISAPI\Response

I am using the code below to call an ISAPI.dll. The dll gets the data ok, but I am trying to send a response back to the php call and not getting anything. What am I missing?

<?php function do_post_request($url, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'POST', 'content' => $data )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php_errormsg"); } return $response; } ?> <?php $data= array('test'=> 'Hello World') ; $data = http_build_query($data); echo do_post_request('http://localhost/MyLogin.dll/Login', $data); ?>

Thanks

Presuming you have full control over your DLL, can you access it without this problem when not using PHP, but directly calling it for example? Or using another script/language? Also, are you using error_reporting(E_ALL) to make sure you get every little issue in the script? I haven’t noticed anything but error_reporting may come up with something. Also, you’re reading data from the stream in binary format. Is this the desired effect? Get rid of the @s in front of your function calls for debugging purposes.

You may consider replacing your Exceptions with simple die() or even echo statements since you’re doing this locally (and not in public or production environment).

Sponsor our Newsletter | Privacy Policy | Terms of Service