php关于接收post过来的xml信息以及给出响应(response)

来源:互联网 发布:王珊数据库第五版 编辑:程序博客网 时间:2024/05/29 07:02

 最近做的项目主要是针对socket以及接收post过来的xml信息并给出响应。

 关于接收post过来xml的信息以及response

 $file_in = file_get_contents('php://input');

 $request = simplexml_load_string($file_in);

$str = "......";

 echo $str;


关于接收response的信息:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);
$response = curl_exec($ch);
if(curl_errno($ch))
{
    print curl_error($ch);
}
var_dump($response);


以上就是一个完整的post发送和接收流程。


关于socket就不多说了。。




0 0
原创粉丝点击