www.webdeveloper.com
Results 1 to 2 of 2

Thread: current crude oil price?

  1. #1
    Join Date
    Nov 2006
    Posts
    64

    current crude oil price?

    I have a website that the client want's the TSX's current crude oil price displayed on. I was able to get their stock info to show (see example below), but the commodities seem to have a different format etc. on the site.

    To show the Talisman info (for example) you would use code like this (works great):

    PHP Code:
    <?php 
        
    Class yahoo 
        

        function 
    get_stock_quote($symbol
        { 
        
    $url sprintf("http://finance.yahoo.com/d/quotes.csv?s=%s&f=sl1d1t1c1ohgv" ,$symbol); 
        
    $fp fopen($url"r"); 
        if(!
    fp
        { 
        echo 
    "error : cannot recieve stock quote information"
        } 
        else 
        { 
        
    $array fgetcsv($fp 4096 ', '); 
        
    fclose($fp); 
        
    $this->symbol $array[0]; 
        
    $this->last $array[1]; 
        
    $this->date $array[2]; 
        
    $this->time $array[3]; 
        
    $this->change $array[4]; 
        
    $this->open $array[5]; 
        
    $this->high $array[6]; 
        
    $this->low $array[7]; 
        
    $this->volume $array[8]; 
        } 
        } 
        } 
        
    $quote = new yahoo
        
    $quote->get_stock_quote("TLM.TO"); 

        echo(
    '<a href="http://tmx.quotemedia.com/quote.php?qm_symbol=TLM" target="_stock" title="Click for more information">');
        echo(
    "<span class='stockTitle'>TLM</span>&nbsp;");
        echo(
    "<span class='blk'>TSX</span>&nbsp;&nbsp;&nbsp;<strong class='red'>$$quote->last</strong>&nbsp;&nbsp;&nbsp;");
        
        if (
    $quote->change ) {
            echo(
    "<span class='red'>$quote->change</span>");
        } else {
            echo(
    "<span class='stockgreen'>$quote->change</span>");
        }
        echo(
    '</a>');
    ?>
    Which then links and shows this data:

    random other stock: http://tmx.quotemedia.com/quote.php?qm_symbol=TLM

    I can't seem to get that same code to show the crude oil price (which I would think would be something very similar). I assume I am missing something simple.

    crude oil info: http://tmx.quotemedia.com/futures-quote.php?qm_page=97237&qm_symbol=/CL:NMX

    If you have any ideas, or other code used to show the TSX crude oil price, I would greatly appreciate the help. Surely someone must have done this before. Thanks!

  2. #2
    Join Date
    Nov 2006
    Posts
    64
    The code doesn't have to be in php if any of you have another way of displaying the crude oil price.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles