I try to get some gamescore information from stats.nba.com via curl :
function getGame($gameID)
{
$url = "http://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=28800&GameID=00" . intval($gameID) . "&RangeType=0&Season=2016-17&SeasonType=Regular+Season&StartPeriod=1&StartRange=0";
$process = curl_init($url);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($process, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
$return = curl_exec($process);
$results = json_decode($return);
curl_close($process);
return $results;
}
In browser this information looks like this:
and takes about 1-2 seconds to load. But via php it takes up to 10-12 seconds to get information. curl_getinfo() shows that starttransfer_time is at 10 seconds:
array(26) {
["url"]=>
string(174) "http://stats.nba.com/stats/boxscoretraditionalv2?EndPeriod=10&EndRange=28800&GameID=0021601068&RangeType=0&Season=2016-17&SeasonType=Regular+Season&StartPeriod=1&StartRange=0"
["content_type"]=>
string(31) "application/json; charset=utf-8"
["http_code"]=>
int(200)
["header_size"]=>
int(384)
["request_size"]=>
int(284)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(10.717)
["namelookup_time"]=>
float(0.046)
["connect_time"]=>
float(0.109)
["pretransfer_time"]=>
float(0.109)
["size_upload"]=>
float(0)
["size_download"]=>
float(5455)
["speed_download"]=>
float(509)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(5455)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(10.686)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(13) "87.245.194.98"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(80)
["local_ip"]=>
string(12) "192.168.1.88"
["local_port"]=>
int(62105)
}
What could be a reason for that and how to fix it?