简体   繁体   中英

How to get JSON parameter from URL

Hello I'm coming from Get JSON object from URL

I tried to get marketCap->usd.

Can anyone tell me what I'm doing wrong please?

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'http://coinmarketcap.northpole.ro/api/v5/ZCL.json');
$result = curl_exec($ch);
curl_close($ch);

$obj = json_decode($result);
echo $result->marketCap->usd;

Change echo $result->marketCap->usd; for echo $obj->marketCap->usd;

You have saved the data decoded in $obj .

您代码的最后一行应该是

echo $obj->marketCap->usd;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM