
Orion Tiller - 2009-01-24 00:51:16
I'm trying to set the referer when I do an HTTP POST request and I don't know what variable to set to do this, any help would be greatly appreciated. Thanks
Also would what gets set be the same for an HTTP GET?
require("http.php");
include('sasl.php');
function http_post( $url, $post_values ) {
$returnvalue = "";
set_time_limit(0);
$http=new http_class;
$http->timeout=0;
$http->data_timeout=0;
$http->debug=0;
$http->html_debug=0;
$http->follow_redirect=1;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
//SET THIS TO SOMETHING FOR REFERER?
$http->request_headers[''] = "";
$http->request_uri = "";
$error=$http->GetRequestArguments($url,$arguments);
$arguments["RequestMethod"]="POST";
$arguments["PostValues"]=$post_values;
$error=$http->Open($arguments);
if($error) die($error);
$error=$http->SendRequest($arguments);
if($error) die($error);
$headers=array();
$error=$http->ReadReplyHeaders(&$headers);
if($error) die($error);
for(;;) {
$error=$http->ReadReplyBody($body,1000);
if ($error!="" || strlen($body)==0)
break;
$returnvalue .= $body;
}
return $returnvalue;
}
$postvalues = array("address" => $address,
"home_area_code" => $phone_area,
"home_prefix" => $phone_prefix,
"home_suffix" => $phone_suffix,
"work_area_code" => $phone_area,
"work_prefix" => $phone_prefix,
"work_suffix" => $phone_suffix);
$ref = "http://www.domainname.com/index_settlement.cgi?cid=4640";
$url = "http://www.domainname.com/index_settlement.cgi";
$result = http_post($url, $postvalues);
//THIS SHOULD WORK USING CURL BUT I WANT TO USE THE ABOVE METHOD
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($postvalues));
curl_setopt($ch,CURLOPT_POSTFIELDS,$poststring);
curl_setopt($ch,CURLOPT_REFERER, $ref);
$result = curl_exec($ch);
curl_close($ch);