Home > Backend Development > PHP Tutorial > 给一个xml格式和一个服务器地址,如何用php写接口

给一个xml格式和一个服务器地址,如何用php写接口

WBOY
Release: 2016-06-13 10:07:50
Original
1075 people have browsed it

给一个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 接什么口?是公还是母?

是公就读数据
是母就输出xml 让别人来分析
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template