I had to ad some slight modification to the currency module in order to access remotely yahoo finance using the following code and the application was working gracefully. I needed to use curl because my host does not allow direct remote file access.

However when I check it today it does not give exchange value. It just gives zero. The website where the application is running is: currency exchange

//$record = file_get_contents($url);
  
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, "$url");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
//$file_contents = curl_exec($ch);
$record = curl_exec($ch);
curl_close($ch);

// display file
//echo $file_contents;

CommentFileSizeAuthor
#3 currency_5.patch737 bytesmeba
#2 currency_4.patch1.2 KBmeba

Comments

wisdom’s picture

Assigned: Unassigned » wisdom
Status: Active » Fixed

changing the url

  /*$url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f='. currency_api_get_fields($currency_array)  
              .'&s='. $from . $to .'=X';*/
  $url = 'http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f='. currency_api_get_fields($currency_array) .'&s='. $from . $to .'=X';

makes it work.

meba’s picture

Category: support » bug
Status: Fixed » Needs work
StatusFileSize
new1.2 KB

This is definitely not "fixed". At least the yahoo URL is stil invalid, but allow_url_fopen is Off on many webhosts. I am attaching the patch doing:

1) Fixing yahoo URL
2) Adding CURL to currency_api, using CURL as default, using file_get_contents() as a fallback

meba’s picture

StatusFileSize
new737 bytes

Some typos, rerolling

amateescu’s picture

Status: Needs work » Closed (fixed)

Latest release from the 5.x branch uses drupal_http_request().