Japps, du kan skicka via post genom att använda följande funktion:
function getURL($method,$host,$port,$path,$param='',$ua=''){
// Build the request string
if(is_array($param)){
$request = array();
foreach($param as $key => $val){
$request[] = $key . "=" . $val;
}
$request = join('&',$request);
}else{
$request = $param;
}
$request_length = strlen($request);
// Build the header
$header = "POST $path HTTP/1.0\r\n";
$header .= "Host: $host\r\n";
if($ua) $header .= "User-Agent: $ua\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "Content-length: $request_length\r\n";
$header .= "\r\n";
// Open the connection
$fp = fsockopen($host,$port,&$err_num,&$err_msg,30);
// No Connection Error
if(!$fp){
die('Sorry, the server is not currently available!');
}
// Send everything
fputs($fp, $header . $request);
// Discard the HTTP header
while(trim(fgets($fp,4096)) != '');
// Get the response
while(!feof($fp)){
$response .= fgets($fp,4096);
}
return $response;
}
$path = "/webservice/item.asp"; //Sökväg till mottagarscript
$host = "www.kurslitteratur.se"; //Domän
$q_arr = array('id' => '1', 'annan_var' => 'värde'); //De ariabler som ska skickas via POST
$response = GetURL('POST',$host, 80, $path, $q_arr,''); //Anropa funktionen och skicka med indata.