+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP Retrieving Stock Data

  1. #1
    jayie1975 is offline x10Hosting Member jayie1975 is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    4

    PHP Retrieving Stock Data

    I have been using the following code to retrieve stock data from Yahoo for over a year now:

    $live = "http://download.finance.yahoo.com/d/quotes.csv?s=" . $_GET["code"] . "&f=sb2m3m7et8n4e7e8e9ia2";
    $file=fopen($live,"r") or exit("Unable to open file!");
    while(!feof($file))
    {
    echo fgets($file). "<br />";
    }
    fclose($file);

    Just recently it has stopped working. I first noticed it on a WordPress Widget I wrote. The only error it gives me is a timeout error. If I leave it to timeout then it obviously suspends my account (which gets annoying after a while). I've been using this code in many PHP Stock Data projects and they have all stopped working! Strangely if you paste the constructed $live string directly as a URL then it works fine. It just shows the data in the web browser as expected. But not in PHP! I've tried using the PHP "file" command to read the constructed URL into an array but it produces the same error.

    I'm I doing something wrong? Help would be appreciated.

    If you'd like a $_GET["code"] variable to test then try 'LLOY.L'

    Many thanks,

    Jason.

  2. #2
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: PHP Retrieving Stock Data

    This is because port 80 has been blocked to all outgoing connections from the free servers. This was put in place to prevent the use of proxies and I don't think it is going to be reversed any time soon.
    If the Yahoo server you are requesting to has the same IP on every request, it is possible that you could have that added to the whitelist for outgoing connections.

  3. #3
    jayie1975 is offline x10Hosting Member jayie1975 is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    4

    Re: PHP Retrieving Stock Data

    Quote Originally Posted by lemon-tree View Post
    This is because port 80 has been blocked to all outgoing connections from the free servers. This was put in place to prevent the use of proxies and I don't think it is going to be reversed any time soon.
    If the Yahoo server you are requesting to has the same IP on every request, it is possible that you could have that added to the whitelist for outgoing connections.
    Thankyou lemon-tree. Do you know if that has been implemented recently? Because that would explain why it's only just stopped working.

    Although strangely my friend uses Hostgator for his websites and this code also fails.

    Jason.

  4. #4
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: PHP Retrieving Stock Data

    It was put in place relatively recently, within the past month or two. I would assume that other hosting companies may have the same system.

+ Reply to Thread

Similar Threads

  1. Error retrieving data
    By ciclo in forum Free Hosting
    Replies: 1
    Last Post: 11-01-2008, 10:42 AM
  2. Error retrieving data
    By ciclo in forum Soporte
    Replies: 1
    Last Post: 10-30-2008, 11:15 AM
  3. Error retrieving account's data
    By aravindv in forum Free Hosting
    Replies: 5
    Last Post: 11-09-2007, 04:26 AM
  4. Error retrieving user data from server...
    By ethraax in forum Free Hosting
    Replies: 1
    Last Post: 10-28-2007, 08:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers