Currency Module Gives Zero Value when using Curl for remote url access

wisdom - September 7, 2007 - 00:04
Project:Currency Exchange
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:wisdom
Status:needs work
Description

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;

#1

wisdom - September 7, 2007 - 23:47
Assigned to:Anonymous» 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.

#2

meba - September 17, 2007 - 16:22
Category:support request» bug report
Status:fixed» needs work

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

AttachmentSize
currency_4.patch 1.2 KB

#3

meba - September 17, 2007 - 16:32

Some typos, rerolling

AttachmentSize
currency_5.patch 737 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.