【问题标题】:CURL with XML post data issue带有 XML 发布数据问题的 CURL
【发布时间】:2012-07-06 06:36:10
【问题描述】:

我正在使用 CURL-PHP 将数据发布到服务器。选项通过 curl_setopt 函数设置为 curl。但不知何故,匿名用户在他的密码中输入了“&”。由于数据是在 xml 中收集的,因此 Xml 的缺点是它停在那里并引发一些 XML 异常。 如果我使用 CDATA,那么它可能无法解析该密码,最终身份验证将失败。我使用了 php 编码函数,如 htmlentities、html_entit_decode、utf8_encode、utf8_encode、urlencode 和 urldecode。但问题是一样的。 是否有任何方法可以通过 XML 发送“&”并通过 CURL 发布该数据。据我所知,CURL 本身在内部进行解析。

谢谢,

【问题讨论】:

标签: php parsing curl encoding xml-parsing


【解决方案1】:

首先确保XML字符串在发布前密码中包含&amp

(<password>123&</password><user password="123&"></user> 对应 123&

htmlentities() 必须应用于 $password,也不能应用于 $xml_data。比确保它附加到像curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data)这样的curl请求;

没有任何额外的编码。它应该工作!在其他情况下,POST 处理程序方面的问题。

【讨论】:

  • 您应该使用一些 ` 来更新您的答案,使其更具可读性。
猜你喜欢
  • 1970-01-01
  • 2016-02-18
  • 1970-01-01
  • 1970-01-01
  • 2011-01-03
  • 2011-01-05
  • 2011-05-18
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多