Jump to content

PHP Stock Quote Display


m u r

Recommended Posts

This piece of php script used to display a stock quote worked beautifully up until a couple weeks ago. I can't figure out why seeing as the yahoo url still downloads the information. Any ideas?

<?php
$ch = curl_init();


curl_setopt( $ch, CURLOPT_URL, 'http://quote.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv' );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );


$output = curl_exec( $ch );
curl_close( $ch );


$contents = explode( ',', str_replace( '"', '', $output ) );


echo "<p>AAPL stock: <b>\$$contents[1]</b> ( $contents[4] )</p>";
?>

Link to comment
https://forums.phpfreaks.com/topic/69621-php-stock-quote-display/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.