【问题标题】:File Get Contents only gets part of JSON data and not all contentsFile Get Contents 只获取 JSON 数据的一部分,而不是所有内容
【发布时间】:2018-09-01 12:28:40
【问题描述】:

下面的代码并没有获取提供的 URL 中的所有 JSON 内容,而是其中的一部分,我找不到任何问题:

$json=file_get_contents("https://fantasy.premierleague.com/drf/bootstrap-static"); 
$data = json_decode($json, true); 
var_dump($data);

【问题讨论】:

标签: php arrays json web-scraping


【解决方案1】:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://fantasy.premierleague.com/drf/bootstrap static");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
$jdecoded = json_decode($data, true); 
curl_close($ch);

print_r($jdecoded);

【讨论】:

  • 它不能在 wamp 服务器上运行,但我已经用 web 服务器进行了测试,它很好。谢谢
  • 检查 wamp 服务器上的“post_max_size”和“memory_limit”PHP INI 设置。这些设置可能太低了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多