2012-03-22 99 views
0

我通过卷曲PHP GET卷曲发布的数据

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 

调用PHP API和发布XML数据。在acertify.php和我无法在PHP文件中的XML数据,我正在一个项目,我不知道在这个,我怎么能卷曲张贴数据在这个文件。

<?php 

echo "hi"; 
print_r($_SESSION); 
print_r($_POST); 
// print_r($_FILES); 

?> 
+1

通过echo $ HTTP_RAW_POST_DATA解决; – XMen 2012-03-22 10:05:43

回答

0

如果你的意思是让POST数据在PHP,那么乍看起来,你要发送一个单场c.setopt(pycurl.POSTFIELDS, "xml="+str(xmldata))

所以它应该只是$_POST['xml']

如果你的意思读数据curl作为响应,然后curl应该在执行时拥有returntransfer选项(我不熟悉python语法)

+0

my $ _POST ['xml']即将空白 – XMen 2012-03-22 09:43:52

+0

我们不能在PHP中编写这个东西吗? – XMen 2012-03-22 09:50:08

+0

也许你应该通过post params作为数组? – 2012-03-22 09:51:40