Re: PHP calling an ISAPI Extension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I modified your code to work with what I'm doing and this is what I got:

$post_data = "name=wow&likes=true";
$fp = fsockopen("localhost",8080);
fwrite($fp,"POST /Project1.dll HTTP/1.1\r\nHost:
localhost\r\nContent-Length:
".strlen($post_data)."\r\n\r\n".$post_data);
$result = fread($fp,102400); // Reads 100KB, change if you need more
echo $result;

Now when I try that I get a "Bad Request invalid header name" error.

I have an IIS server running localy on port 8080, the Project1.dll is in the root directory, it contains two input components 1 a textfield to type your name, the other a checkbox called likes. What's wrong? Here's it's code:

<html>
<head>
<title>Learning ISAPI</title>
</head>
<h3>Learning ISAPI!</h3>
<form name="isapiform" method="POST" action="/Project1.dll">
<strong>Please enter the following information</strong>
<br>Name: <input type="text" name="name">
<br><input type="checkbox" name="likes" value="true" checked> I like ISAPI!<p>
<input type="submit" value="View Output">
</form>
</html>

"Tijnema" <tijnema@xxxxxxxxx> wrote in message news:d8269d910706190041m6e5ee258wfb95336b9c362c60@xxxxxxxxxxxxxxxxx
On 6/19/07, Jim Lucas <lists@xxxxxxxxx> wrote:
Dan wrote:
> I wish I could, I can't count on the script being on a linux machine. > I
> also can't expect people to rebuild PHP with the curl library just to
> use my script. Is there any other way to do a post to a page from a > php
> function?
>
> - Daniel
>
> "Jim Lucas" <lists@xxxxxxxxx> wrote in message
> news:46770D93.6010003@xxxxxxxxxxxx
>> Dan wrote:
>>> I would normaly do it with an AJAX call but I need to do a post from
>>> WITHIN a PHP function, so when it's doing php stuff
>>> ex.
>>> function something()
>>> {
>>> echo 'whatever';
>>> $response = post some data to a ISAPI Extension eg. post to
>>> http://domain.com/scripts/app.dll
>>> return $response . "other data";
>>> }
>>>
>>>
>>> ""Jay Blanchard"" <jblanchard@xxxxxxxxxx> wrote in message
>>> news:56608562F6D5D948B22F5615E3F57E690245F0AC@xxxxxxxxxxxxxxxxxxxxxxxxxx
>>> [snip]
>>> I'm in need of a way to contact an ISAPI Extension from a PHP >>> function. >>> Does anyone know how I would be able to do this? Usually you would >>> post
>>> a
>>> page to their URL/actionname.  Can I do a POST from a PHP function
>>> without
>>> reloading the page, and get a result back?  That's one tall order.
>>> Anyone
>>> want to give it a shot?
>>> [/snip]
>>>
>>> Do the POST with an AJAX call
>>
>> perform an ajax call the a php script that calls curl to do a post to
>> the ISAPI extension
>>
>> --
>> Jim Lucas
>>
>>    "Some men are born to greatness, some achieve greatness,
>>        and some have greatness thrust upon them."
>>
>> Twelfth Night, Act II, Scene V
>>     by William Shakespeare
>
The only method that I am aware of is the fsockopen method you mention in your other email

--
Jim Lucas

Yes, and what's wrong with it?
<?php
$post_data = "form_a=1&form_b=4";
$fp = fsockopen("www.domain.com",80);
fwrite($fp,"POST /scripts/app.dll HTTP/1.1\r\nHost:
www.domain.com\r\nContent-Length:
".strlen($post_data)."\r\n\r\n".$post_data);
$result = fread($fp,102400); // Reads 100KB, change if you need more
?>

That's not too long is it?

Tijnema


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux