php获取发布的数据
我正在通过curl调用一个php apiphp获取发布的数据,php,curl,Php,Curl,我正在通过curl调用一个php api ncServerURL='http://myserver/acertify.php' # binaryptr = open('sampleamex.xml','rb').read() # print binaryptr c = pycurl.Curl() c.setopt(pycurl.URL, ncServerURL) c.setopt(pycurl.POST, 1) c.setopt(pycurl.SSL_VERIFYPEER
ncServerURL='http://myserver/acertify.php'
# binaryptr = open('sampleamex.xml','rb').read()
# print binaryptr
c = pycurl.Curl()
c.setopt(pycurl.URL, ncServerURL)
c.setopt(pycurl.POST, 1)
c.setopt(pycurl.SSL_VERIFYPEER, 0)
c.setopt(pycurl.SSL_VERIFYHOST, 0)
header=["Content-type: text/xml","SOAPAction:run",'Content-Type: text/xml; charset=utf-8','Content-Length: '+str(len(xmldata))]
# print header
c.setopt(pycurl.HTTPHEADER, header)
c.setopt(pycurl.POSTFIELDS, "xml="+str(xmldata))
import StringIO
b = StringIO.StringIO()
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.perform()
ncServerData = b.getvalue()
return ncServerData
以及发布xml数据。在acertify.php中,我无法在php文件中使用xml数据,我正在从事一个项目,我不知道在这个项目中,如何才能在这个文件中获取发布的数据
<?php
echo "hi";
print_r($_SESSION);
print_r($_POST);
// print_r($_FILES);
?>
如果您的意思是用php获取POST数据,那么乍一看,您似乎在发布单个字段c.setoptpycurl.POSTFIELDS,xml=+strxmldata 所以它应该是$\u POST['xml']
如果你的意思是用curl作为响应读取数据,那么curl在执行时应该有returntransfer选项,我不熟悉python语法my$_POST['xml']是空的,也许你应该将POST参数作为数组传递?由echo$HTTP_RAW_POST_data解决;