Use drupal_http_request instead of file_get_contents to make it work with webservers behind proxy
Johnny vd Laar - March 11, 2008 - 16:08
| Project: | Stock API |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
Description
I was testing this module but because i'm behind a proxy it's not possible for me to use the "file_get_contents" function. I've modified my drupal such that drupal_http_request functions work with my proxy (http://drupal.org/node/7881)
I think it's good practice to use the drupal_http_request function instead of the standard php file_get_contents feature so I modified the stock api module to work with the drupal_http_request function.
I took the 5.x-1.0 version from 2007-Jun-02. And this is my modification:
line 102
$contents = @file_get_contents($url);
if ($contents) {
if ($data = explode(',', str_replace('"', '', $contents))) {
$data = array_map('trim', $data);
return $data;
}
}becomes:
$contents = drupal_http_request($url);
if ($contents) {
if ($data = explode(',', str_replace('"', '', $contents->data))) {
$data = array_map('trim', $data);
return $data;
}
}
#1
http://drupal.org/node/218125