'm trying to access a web service that requires a POST operation, and I've managed to so in at least three different ways, but it's always SLOW!! My first try used fsockopen() and associated functions, and took about 30 seconds to get an answer. Then I tried the socket_xxxxx() functions, but the results were similar. Finally I used the curl_xxxxx() functions, and yet the same result. HOWEVER, I also did a similar try with Python, and I got the answer within 2 seconds! All the PHP programs worked fine, and so did the Python one, but I couldn't get any speed out of PHP. Are there any known restrictions/problems with this? Any solutions? Thanks!
This is the curl way I tried: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $urlToOpen.$pathToOpen); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Accept-Encoding: identity")); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Connection: close")); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: binary/octet-stream")); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Length: ".strlen($dataToSend))); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataToSend); $answer = curl_exec($ch); curl_close($ch); And it was every bit as slow as the fsockopen() or socket_xxx() versions!