On Wednesday, June 26, 2002, at 10:49 AM, Laurent Drouet wrote:
> I would like to know if there is a way to request data from a web
> for example http://glkev.net.innerhost.com/glkev_ws/Currencyws.asmx
> using php without java ?
If you know the web services API, you just send your request. It
shouldn't matter whether you're using Java, PHP, Python, even VB or even
Telnet to generate your request -- most web services accept an HTTP POST
message consisting of XML code which is used to perform some kind of
There are two things you can do -- either use the cURL functions (your
PHP binary must be compiled with cURL enabled to do this), which give
you an advanced set of URL accesses, or open a socket to the remote
machine with the web service and send a stream of POST data that way.
You can use Rasmus Lerdorf's "postToHost" function (this may as well
just become a PHP function, it gets referenced so much), which I have
appended to this message.
Either way, just generate your XML string and fire it at the remote
machine. You will need to write code to handle the response, obviously.
# PostToHost($host, $path, $data_to_send)
# "It is a trivial little function."
function PostToHost($host, $path, $data_to_send)
$fp = fsockopen($host,80);
fputs($fp, "POST $path HTTP/1.0\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data_to_send) . "\n");
fputs($fp, "Connection: close\n\n");
echo fgets($fp, 128);
Web Developer Temp
Media Lab, H.H. Brown
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php