Why is file_get_contents returning page source?

Aha, I figured it out! You have to use wp_remote_get(). I’m not exactly sure why at this point, but here’s what the code looks like:

function display_csv_data_func( $atts ) {
   $file_path = "http://example.com/something/file.csv";
   $response = wp_remote_get($file_path);
   $response_body = wp_remote_retrieve_body($response);
   return "<script>alert('" . $response_body . "');</script>";
}
add_shortcode( 'display_csv_data', 'display_csv_data_func' );