neomaximus2k
03-04-2009, 12:00 PM
hey guys, having major problems with this and its beggining to annoy me now.
I need to send post data using php to our server and handle the response. At present the code i have is
$postdata = 'username=test&key=gdfghsjkhtr234ir';
$fp = fsockopen("test.servername.co.uk", 80, $errno, $errstr, 30);
fputs($fp, "POST /testapisystem2.php HTTP/1.0\r\n");
fputs($fp, "Host: test.servername.co.uk\r\n");
fputs($fp, "Content-type: application/x-www-form- urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "User-agent: Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $postdata);
while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
echo $buf;
The request is received by the script as shown by the logs for the server however there are no post variables received!
on the receiving script I have performed a print_r($_POST) and there are no post variables at all!!
I cant use cURL as not all servers have this enabled and I need to provide the php framework to other people to use.
so does anyone have any ideas why the post vars are not getting to the file?
I have also tried the script on a different server (different OS as well as configuration) and still get the same problem
I need to send post data using php to our server and handle the response. At present the code i have is
$postdata = 'username=test&key=gdfghsjkhtr234ir';
$fp = fsockopen("test.servername.co.uk", 80, $errno, $errstr, 30);
fputs($fp, "POST /testapisystem2.php HTTP/1.0\r\n");
fputs($fp, "Host: test.servername.co.uk\r\n");
fputs($fp, "Content-type: application/x-www-form- urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "User-agent: Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $postdata);
while (!feof($fp)) {
$buf .= fgets($fp,128);
}
fclose($fp);
echo $buf;
The request is received by the script as shown by the logs for the server however there are no post variables received!
on the receiving script I have performed a print_r($_POST) and there are no post variables at all!!
I cant use cURL as not all servers have this enabled and I need to provide the php framework to other people to use.
so does anyone have any ideas why the post vars are not getting to the file?
I have also tried the script on a different server (different OS as well as configuration) and still get the same problem