Method 1: HTTP function sending Method
Description: $ data is the data sent by POST. $ key is the parameter name and $ val is the parameter value.
[Php]View plaincopy
$ URL = "http://pre.payment.sdoa.sdo.com /";
$ Data = $ key1. "=". val1. "&". $ key2. "=". val2;
$ PostResult = http_post_data ($ BGWURL, $ data );
Method 2: Curl Post Data
[Php]View plaincopy
Function _ curl_post ($ url, $ vars ){
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, "var =". $ vars );
$ Data = curl_exec ($ ch );
Curl_close ($ ch );
If ($ data)
Return $ data;
Else
Return false;
}
Method 3: fsockopen
Description: $ data is the data sent by POST. $ data is an array.
[Php]View plaincopy
Function posttohost ($ url, $ data ){
$ Url = parse_url ($ url );
If (! $ Url) return "couldn't parse url ";
If (! Isset ($ url ['Port']) {$ url ['Port'] = "";}
If (! Isset ($ url ['query']) {$ url ['query'] = "";}
$ Encoded = "";
While (list ($ k, $ v) = each ($ data )){
$ Encoded. = ($ encoded? "&":"");
$ Encoded. = rawurlencode ($ k). "=". rawurlencode ($ v );
}
$ Fp = fsockopen ($ url ['host'], $ url ['Port']? $ Url ['Port']: 80 );
If (! $ Fp) return "Failed to open socket to $ url [host]";
Fputs ($ fp, sprintf ("POST % s HTTP/1.0/n", $ url ['path'], $ url ['query']? "? ":" ", $ Url ['query']);
Fputs ($ fp, "Host: $ url [host]/n ");
Fputs ($ fp, "Content-type: application/x-www-form-urlencoded/n ");
Fputs ($ fp, "Content-length:". strlen ($ encoded). "/n ");
Fputs ($ fp, "Connection: close/n ");
Fputs ($ fp, "$ encoded/n ");
$ Line = fgets ($ fp, 1024 );
If (! Eregi ("^ HTTP/1/.. 200", $ line) return;
$ Results = ""; $ inheader = 1;
While (! Feof ($ fp )){
$ Line = fgets ($ fp, 1024 );
If ($ inheader & ($ line = "/n" | $ line = "/r/n ")){
$ Inheader = 0;
}
Elseif (! $ Inheader ){
$ Results. = $ line;
}
}
Fclose ($ fp );
Return $ results;
}