Re: Posting to URL using PHP
Here you go:
Code:
//
// Illustrates the steps you take to POST with PHP...
//
function DoPost($data)
{
// fix up your data like you like it
$data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>".$data;
// now make a POST request
$send = "POST /whereever.php HTTP/1.1\r\n";
$send .= "Host: http://www.somesite.com \r\n";
$send .= "Content-type: application/x-www-form- urlencoded\r\n";
$send .= "Content-length: " . strlen($data) . "\r\n";
$send .= "Connection: close\r\n\r\n";
$send .= $data;
// now connect to the place where you want to send it
$fp = fsockopen("http://www.somesite.com", 80);
// now send it
fputs($fp, $send);
//now read the result
$result = "";
while (!feof($fp)) {
$result .= fgets($fp,128);
}
fclose($fp);
//now return the result
return $result;
}
This is something pretty close to what you want, I did not try and debug it, but I've done code like that before. Use that as an example and you can do it, but keep in mind I did not actually try that code sample on my site to debug it or not, its just to show you the steps you have to do.
Re: Posting to URL using PHP
Brilliant.. thank you so much!!
The trouble with this web site.. especially after you have spent 2 hours trying to work something out... is that it is too tempting to come here and ask your question and save the effort!!! ;-)
Actually, no.. I won't do that because I won't learn properly... but it is tempting.
Thanks again, I am off to decipher it all :)
A.