[Solved] Download json file from web and view in php


Try using CURL instead..

<?php

$url = "https://prices.csgotrader.app/latest/prices_v6.json";

$options = [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HEADER => false,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_ENCODING => "",
  CURLOPT_USERAGENT => "CURL",
  CURLOPT_AUTOREFERER => true,
  CURLOPT_CONNECTTIMEOUT => 120,
  CURLOPT_TIMEOUT => 120,
  CURLOPT_MAXREDIRS => 10
];

$ch = curl_init ($url);
curl_setopt_array ( $ch, $options );

$return = [];
$return['response'] = curl_exec ( $ch );
$return['errno'] = curl_errno ( $ch );
$return['errmsg'] = curl_error ( $ch );
$return['httpcode'] = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );

curl_close ($ch);

if($return['httpcode'] == 200)
{
    echo $return['response']; //Here is your response

}

?>

Here is a working example https://paiza.io/projects/e/rMwG3pOC6sRdA89gU885ag

solved Download json file from web and view in php