douzhanshen0657
2016-06-27 11:29
浏览 150
已采纳

从curl获取特定数据

I want to get the value of the variable in the JSON but it keeps on giving me undefined index where the index is definitely there when I open the URL.

Here is my code:

 //initializing cURL
            $ch = curl_init();
//setting the URL
            $priceURL = 'http://steamcommunity.com/market/priceoverview/?currency=1&appid=570&market_hash_name=Exalted%20Manifold%20Paradox';
//set options
            curl_setopt($ch, CURLOPT_URL, $priceURL);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HEADER, 0);
//execute
            $string1 = curl_exec($ch);
//close curl session/free resources
            curl_close ($ch);
//decode the json string into an array
            $json_price_file = json_decode($string1, true);
            $price = $json_price_file ["lowest_price"];

It gives an error of Undefined index: lowest_price. However, when you open the URL, the variable is definitely there. What am I missing? Please help :D

1条回答 默认 最新

相关推荐 更多相似问题