Stock Quote Display PHP

Discussion in 'PHP' started by m u r, Sep 16, 2007.

  1. #1
    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>";
    ?>
    Code (markup):

     
    m u r, Sep 16, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
  3. m u r

    m u r Guest

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So in this case, http://download.finance.yahoo.com/d/AAPL&f=1c1ohgv&e=.csv ??? Where do I put the ticker symbol?
     
    m u r, Sep 16, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Uh? Just replace the old URL with this one and it'll work.
     
    nico_swd, Sep 16, 2007 IP
  5. m u r

    m u r Guest

    Messages:
    5
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv

    Thanks!
     
    m u r, Sep 16, 2007 IP
    dynashox likes this.