首页 > 开发 > PHP > 正文

php fsockopen post数据发送实例

2024-05-04 21:59:23
字体:
来源:转载
供稿:网友
  1. function do_call($host,$port,$request)         //定义函数 
  2.   $fp=fsockopen($host,$port,$errno,$errstr); 
  3.   $query="post /default/php/server.php http/1.0nuser_agent:this is a dummy clientnhost:"
  4.   $host."ncontent-type:text/xmlncontent-length:"
  5.   strlen($request)."nn".$request."n"
  6.   if(!fputs($fp,$query,strlen($query))) 
  7.   {//开源代码Vevb.com 
  8.     $errstr="write error"
  9.     return 0; 
  10.   } 
  11.   $contents=''
  12.   while(!feof($fp)) 
  13.   { 
  14.     $contents.=fgets($fp); 
  15.   } 
  16.   fclose($fp); 
  17.   return $contents; 
  18. $host='localhost';            //定义host地址 
  19. $port=80;              //定义端口 
  20. $obj->type="datetime";           //定义对象 
  21. $obj->scalar="20040420t13:32:40"
  22. $obj->timestamp=1082460760; 
  23. $request=xmlrpc_encode_request('dummyserver',$obj);     //为php生成xml 
  24. $response=do_call($host,$port,$request);        //调用函数 
  25. $xmlrpctype=xmlrpc_get_type($response);       //获取xmlrpc类型 
  26. print_r($xmlrpctype);            //输出结果 
  27. ?>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表