解析来自远程服务器的JSON数据 [英] Parsing JSON data from a remote server
本文介绍了解析来自远程服务器的JSON数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有任何方法可以在PHP中使用解析器从该网站获取值 https://btc-e.com/api/2/btc_usd/ticker
并将其设置为php代码中的变量?
I was wondering if there was any way to make a Parser in PHP in which gets the values from this site https://btc-e.com/api/2/btc_usd/ticker
and sets them as variables in php code?
我稍微看过php解析器,发现的唯一一件事就是解析器,该解析器回显了网站上的所有信息.
I have looked at php parsers a bit and the only thing I found was parsers that echo all the information on a website.
推荐答案
由于该URL返回了JSON
响应:
Since that URL returns a JSON
response:
<?php
$content=file_get_contents("https://btc-e.com/api/2/btc_usd/ticker");
$data=json_decode($content);
//do whatever with $data now
?>
这篇关于解析来自远程服务器的JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文