Ticker:
{"high": "145.00", "last": "143.92", "timestamp": "1382049657", "bid": "143.81", "volume": "17883.09636191", "low": "135.00", "ask": "143.92"}
我如何从这张票中“询问”价值?
我使用此代码来获取它:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.bitstamp.net/api/ticker/');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$getit= curl_exec($ch);
curl_close($ch);
echo $getit;
答案 0 :(得分:2)
网站回复位于JSON,您必须先使用json_decode将其解码为数组。
$ticket = json_decode($getit, true);
echo $ticket['ask'];