|
-
August 12th, 2005, 01:11 PM
#2
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|