【问题标题】:how to parse response from cellcom using that url?如何使用该 url 解析来自 cellcom 的响应?
【发布时间】:2015-04-07 00:13:31
【问题描述】:

我正在尝试从我的 php 脚本中读取此网址:

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

请先加载网址,查看响应并告诉我该怎么做。

我尝试了以下方法:

file_get_contents
simplexml_load_string 
simplexml_load_file
CURL

在所有情况下都失败了。 我已保存 xml 并将其上传到

http://vtopup.tk/1.xml

我可以读这个,但不是原来的。 请帮我。我已经厌倦了搜索和申请......

谢谢。

【问题讨论】:

  • SimpleXML 无疑是最简单的方法。当你写“在所有情况下都失败”时,你具体看到了什么,当你打电话给simplexml_load_file( 'http://test.cellpay.com.np:8181/cellcom?FN=ATW&fromMobile=testuser&phoneNumber=01670746301&PIN=z2ag&amount=0' );
  • bool(false),虽然url有效,但在vtopup.tk/1.xml的情况下有效
  • @Shuhail 那么你还有另一个问题,也许你身边有些东西“坏了”,
  • 是的!当然!但找不到....我快疯了....相同的代码为不同的 url 运行,相同的 url 在我的浏览器中运行,这意味着 url 和我的代码都很好......但无法匹配。 ..

标签: php api


【解决方案1】:

!!!!!!!!!终于解决了!!!!!!!!! 这就是关于 php 版本的全部内容 我从 PHP 5.4.27 开始尝试,不起作用.... 最后从 PHP 5.6.3 开始尝试,它可以工作。如此简单而神奇。

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

谢谢大家,非常感谢。

【讨论】:

    【解决方案2】:

    经过测试,它正在工作。

    <?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);
    

    【讨论】:

    • 我把你的代码...但是...警告:simplexml_load_file(): in /home/icetopup/public_html/api/index.php on line 3 警告: simplexml_load_file(): ^ in / home/icetopup/public_html/api/index.php 第 3 行提要未加载 [请检查 icetopup.tk/api/index.php]
    • @Shuhail 你能试试$url = 'http://test.cellpay.com.np:8181/cellcom?FN=ATW&amp;fromMobile=testuser&amp;phoneNumber=01670746301&amp;PIN=z2ag&amp;amount=0'; $data = file_get_contents($url); var_dump($data);
    • 字符串(0)“”。你得到你的回应了吗?
    • @Shuhail 是的,我收到了回复,所以您的 ip 可能被阻止或类似情况。您可以尝试从服务器 ping 到它。
    • 我正在从服务器 icetopup.tk/api/index.php 尝试它,我应该从我的本地主机尝试它吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    相关资源
    最近更新 更多