If I want to get the data from champion.gg
over my browser, I get everything. If I try to get it over file_get_contents
, I only get the half page
after "Galio" the string is cut off.
Chrome: http://api.champion.gg/stats?api_key=PRIVATE about 86.000 chars file_get_contents("http://api.champion.gg/stats?api_key=PRIVATE"); about 45.000 chars
Try using cURL:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.champion.gg/stats?api_key=PRIVATE");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($ch);
curl_close($ch);
var_dump($data); // $data should contain the response
Increase the timeout value if you get incomplete responses.