我有以下文本,我想去掉並獲取數據。從JSON中去除不需要的值
(function() {})({
"Data": {
"Status": "SUCCESS",
"Name": "Facebook Inc",
"Symbol": "FB",
"LastPrice": 31.91,
"Change": -1.12,
"ChangePercent": -3.39085679685135,
"Timestamp": "Fri May 25 16:00:05 UTC-04:00 2012",
"MarketCap": 20214729720,
"Volume": 37189630,
"ChangeYTD": 0,
"ChangePercentYTD": 0,
"High": 32.95,
"Low": 31.11,
"Open": 32.9
}
})
我也有下面的代碼是與谷歌API的工作,這將在今年十月離開我們。
<?php
//Obtain Quote Info
$quote = file_get_contents('http://finance.google.com/finance/info?client=ig&q=NASDAQ:' . $stock . '');
//Remove CR's from ouput - make it one line
$json = str_replace("\n", "", $quote);
//Remove //, [ and ] to build qualified string
$data = substr($json, 4, strlen($json) -5);
//decode JSON data
$json_output = json_decode(utf8_decode($data));
// get the last price
$perc = $json_output->c;
$last = $json_output->l;
$date = $json_output->lt;
$name = $json_output->t;
?>
無論出於何種原因,我無法弄清楚如何讓其他人使用我的代碼。任何人有任何建議?
你想擺脫哪些角色? –
(函數(){})({ 「數據」:{ –
是否是Google API請求的結果,還是你從某處刮取? –