function stats_get_remote_csv($url) { $method = 'GET'; $timeout = 90; $user_id = JETPACK_MASTER_USER; $get = Jetpack_Client::remote_request(compact('url', 'method', 'timeout', 'user_id')); $get_code = wp_remote_retrieve_response_code($get); if (is_wp_error($get) || 2 != intval($get_code / 100) && 304 != $get_code || empty($get['body'])) { return array(); // @todo: return an error? } else { return stats_str_getcsv($get['body']); } }
function stats_get_remote_csv($url) { $url = clean_url($url, null, 'url'); // Yay! if (ini_get('allow_url_fopen')) { $fp = @fopen($url, 'r'); if ($fp) { //stream_set_timeout($fp, $timeout); // Requires php 4.3 $data = array(); while ($remote_read = fgetcsv($fp, 1000)) { $data[] = $remote_read; } fclose($fp); return $data; } } // Boo - we need to use wp_remote_fopen for maximium compatibility if (!($csv = wp_remote_fopen($url))) { return false; } return stats_str_getcsv($csv); }