dongxindu8753 2012-02-23 00:21
浏览 48
已采纳

使用PHP进行货币转换JSON API解析

Could anyone help me parse this JSON API with PHP? I need to retrieve the currency exchange rate.

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22eurusd%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=cbfunc

  • 写回答

2条回答 默认 最新

  • doulingna9420 2012-02-23 16:16
    关注

    At first you need to omit the last parameter in the URL, just remove &callback=cbfunc.

    The PHP code to fetch the content is:

    $rawData = file_get_contents("... your url ...");
    $parsedData = json_decode($rawData);
    

    $parsedData will now contain the content in a nested object structure.

    Further info

    You need fopen wrappers enabled for this to work. If they are not enabled, just use cURL to load the content from the page and put it into json_decode.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料