首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >php获取curl posted数据

php获取curl posted数据
EN

Stack Overflow用户
提问于 2012-03-22 17:38:39
回答 1查看 1K关注 0票数 0

我通过curl调用php api。

代码语言:javascript
复制
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数据,我正在做一个项目,我不知道在这个项目中,我怎样才能在这个文件中获得curl发布的数据。

代码语言:javascript
复制
<?php

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

?>
EN

回答 1

Stack Overflow用户

发布于 2012-03-22 17:41:22

如果你的意思是在php中获取帖子数据,那么乍一看你就像是在张贴一个字段c.setopt(pycurl.POSTFIELDS, "xml="+str(xmldata))

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

如果您的意思是使用curl作为响应来读取数据,那么curl应该在执行时具有returntransfer选项(我不熟悉python语法)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9819636

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档