php fsockopen post数据发送实例 |
时间:2015-01-23 来源:西部数据 作者:西部数据 |
|
- function do_call($host,$port,$request)
- {
- $fp=fsockopen($host,$port,$errno,$errstr);
- $query="post /default/php/server.php http/1.0nuser_agent:this is a dummy clientnhost:".
- $host."ncontent-type:text/xmlncontent-length:".
- strlen($request)."nn".$request."n";
- if(!fputs($fp,$query,strlen($query)))
- {
- $errstr="write error";
- return 0;
- }
- $contents='';
- while(!feof($fp))
- {
- $contents.=fgets($fp);
- }
- fclose($fp);
- return $contents;
- }
- $host='localhost';
- $port=80;
- $obj->type="datetime";
- $obj->scalar="20040420t13:32:40";
- $obj->timestamp=1082460760;
- $request=xmlrpc_encode_request('dummyserver',$obj);
- $response=do_call($host,$port,$request);
- $xmlrpctype=xmlrpc_get_type($response);
- print_r($xmlrpctype);
- ?>
|
|
|
|