2015-02-06 58 views
0

我想從我的PHP腳本讀取這個網址:如何使用該url解析來自cellcom的響應?

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

請先加載的URL,檢查響應,並告訴我該怎麼做。

我試過如下:

file_get_contents 
simplexml_load_string 
simplexml_load_file 
CURL 

未能在所有情況下。 我已經保存在XML,並上傳到

http://vtopup.tk/1.xml 

我可以讀這一點,但不是原來的一個。 請幫幫我。我厭倦了搜索和應用...

謝謝。

+0

SimpleXML肯定是最簡單的方法。當你寫'所有情況下都失敗'時,當你調用'simplexml_load_file('http://test.cellpay.com.np:8181/cellcom?FN=ATW&fromMobile=testuser&phoneNumber=01670746301&PIN=z2ag&amount=0 ');' – Saeven 2015-02-06 19:01:10

+0

布爾(假),雖然網址是有效的,但它的工作http://vtopup.tk/1.xml的情況下 – Shuhail 2015-02-06 19:04:35

+0

@Shuhail然後你有另一個問題,也許有什麼是「破」在你身邊, – VeeeneX 2015-02-06 19:12:44

回答

0

!!!!!!!!!終於解決了!!!!!!!!! 這就是所有關於PHP版本 我試圖從PHP 5.4.27,不工作.... 終於嘗試從PHP 5.6.3,它的工作原理。如此簡單而神奇。

感謝Veenexfile_get_contents returns empty string 盡全力。

謝謝你們,非常感謝。

0

經過測試,它的工作。

<?php 
$url = 'http://test.cellpay.com.np:8181/cellcom?FN=ATW&fromMobile=testuser&phoneNumber=01670746301&PIN=z2ag&amount=0'; 
$xml = simplexml_load_file($url) or die("feed not loading"); 
var_dump($xml); 
+0

我把你的代碼...但是...警告:simplexml_load_file():在/home/icetopup/public_html/api/index.php在線3 警告:simplexml_load_file():^ in/home/icetopup第3行的/public_html/api/index.php feed未加載[請檢查http://icetopup.tk/api/index.php] – Shuhail 2015-02-06 19:14:34

+0

@Shuhail你可以試試'$ url ='http:// test。 cellpay.com.np:8181/cellcom?FN=ATW&fromMobile=testuser&phoneNumber=01670746301&PIN=z2ag&amount=0' ; \t $ data = file_get_contents($ url); \t var_dump($ data);' – VeeeneX 2015-02-06 19:23:10

+0

string(0)「」。你是否從你的最後得到了迴應? – Shuhail 2015-02-06 19:24:50