如何使用php处理XML响应

时间:2015-02-06 10:58:21

标签: php xml

我需要ping该URL并收到回复:

http://test.cellpay.com.np:8181/cellcom?FN=123&fromMobile=01670746301&phoneNumber=01970746301&PIN=1234567890&amount=0

响应采用XML格式。我试图用PHP读取响应。 如果我使用:

file_get_contents($url);

它显示:

file_get_contents(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0

如果我使用:

file_get_contents($url);

它显示:

bool(false) 
Uncaught exception 'Exception' with message 'String could not be parsed as XML'

我不知道该怎么做,请帮助我。

感谢。

2 个答案:

答案 0 :(得分:0)

  

http://在服务器配置中禁用了包装器   allow_url_fopen选项= 0

您的服务器不允许使用PHP流包装器打开http网址。您可以尝试使用ext/curlfsockopen()。但是,您可能没有将Server / PHP配置为支持传出连接。

答案 1 :(得分:0)

!!!!!!!!!终于解决了!!!!!!!!!  这些都是关于php版本的 我试过PHP 5.4.27,没有工作.... 最后尝试从PHP 5.6.3,它的工作原理。如此简单而神奇。

感谢Veenexfile_get_contents returns empty string  尽一切努力。

谢谢你们,非常感谢你们。