1

I need to ping that URL and receive response:

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

The response is in XML. I am trying to read the response using PHP. if I use:

file_get_contents($url);

it shows:

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

if I use:

file_get_contents($url);

it shows:

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

I don't know what to do, please help me.

Thanks.

Shuhail
  • 58
  • 1
  • 9
  • 1
    Change the setting given in the first error message, or find a new host. – rjdown Feb 06 '15 at 11:01
  • You can use PHP xml parser. May be this can help you http://stackoverflow.com/questions/188414/best-xml-parser-for-php – shakthydoss Feb 06 '15 at 11:01
  • I've talked to my Hosting Server and enabled the url_fopen. but still it returns, bool(false) . your link suggest how to handle data. but I am having problem with receiving data. please tell me how to receive data. Please check the link [link]http://test.cellpay.com.np:8181/cellcom?FN=123&fromMobile=01670746301&phoneNumber=01970746301&PIN=1234567890&amount=0[/link] is it xml? – Shuhail Feb 06 '15 at 14:29

2 Answers2

0

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

Your server does not allow to open http urls with PHP stream wrapper. You can try to use ext/curl or fsockopen(). But it is possible that you Server/PHP is just not configured to support outgoing connections.

ThW
  • 19,120
  • 3
  • 22
  • 44
  • I can parse http://vtopup.tk/1.xml but could not parse http://test.cellpay.com.np:8181/cellcom?FN=ATW&fromMobile=testuser&phoneNumber=01670746301&PIN=z2ag&amount=0 ........................ please please please check the out put before dropping your advice....thanks. – Shuhail Feb 06 '15 at 18:21
  • You posted the error message from your server, on my servers the http streamwrapper is usually not disabled. – ThW Feb 06 '15 at 18:52
  • I asked the host to enable the wrapper, and they enabled it. but still I can read the response, it always shows bool(false). but the url is valid. please load the url once and check the response, may be you will understand my problem. I've tried file_get_contents, simplexml_load_string, simplexml_load_file, curl.... not nothung change.... please help me. – Shuhail Feb 06 '15 at 18:56
0

!!!!!!!!!Finally solved!!!!!!!!! Thats all about php versions I was trying from PHP 5.4.27, doesn't work.... Finally tried from PHP 5.6.3 and it works. so simply and magically.

Thanks to Veenex and file_get_contents returns empty string for all effort.

Thank you guys, thank you very much.

Community
  • 1
  • 1
Shuhail
  • 58
  • 1
  • 9