我是php新手,需要使用他们的API查询oracle数据库。我只能将查询作为xml或json发送到正文中。我不确定我做得对。请找到代码
<?php
//HTTP Headers
$header = array('Content-Type = application/xml','Accept = application/xml');
$xmlquery = <<<XML
---- query----
XML;
$body = simplexml_load_string($xmlquery);
//URL containing query parameters : appGUID, pagenumber, pagesize
$url='http://<server name>?appGUID=<GUID>&pagenumber=1&pagesize=50';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$body);
//CURLOPT_POSTFIELDS : The full data to post in a HTTP "POST" operation.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
var_dump ($response);
curl_close($ch);
?>
答案 0 :(得分:0)
Simplexml_load_string返回一个包含xml字符串属性的对象。 Curl_post期望您的有效负载不是对象。您应该能够直接发布XML字符串。