给一个xml格式和一个服务器地址,怎么用php写接口
我最近正在写,不知道大牛们会怎么写,想学习学习
^…………
------解决方案--------------------
啥接口得给出来吧?
------解决方案--------------------
这是提交数据,调用就简单了,直接fso_get_contents,然后分析xml就行了
$url="https://xxx.com/xml";
$ch = curl_init ($url);
$headers = array(
"POST ".$url." HTTP/1.0",
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Content-length: ".strlen($xmlcontent),
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
// Apply the XML to our curl call
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlcontent);
$data = curl_exec($ch);
if (curl_errno($ch)) {
die('会议信息出错,有可能会议还未开始!');
exit;
} else {
// Show me the result
//var_dump($data);
curl_close($ch);
}
------解决方案--------------------
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号