I'm trying to get data from an API in symfony. here's my code:
$champion_details_json = file_get_contents('https://global.api.pvp.net/api/lol/static-data/euw/v1.2/champion?api_key=mykey');
$obj2 = json_decode($champion_details_json);
$championDetailData = $obj2->data;
return $this->render('default/action.html.twig', compact('championData', 'championDetailData'));
Here's what a var dump shows me on the screen:
object(stdClass)[386]
public 'Thresh' =>
object(stdClass)[385]
public 'id' => int 412
public 'key' => string 'Thresh' (length=6)
public 'name' => string 'Thresh' (length=6)
public 'title' => string 'the Chain Warden' (length=16)
public 'Aatrox' =>
object(stdClass)[387]
public 'id' => int 266
public 'key' => string 'Aatrox' (length=6)
public 'name' => string 'Aatrox' (length=6)
public 'title' => string 'the Darkin Blade' (length=16)
Here's what the api's tells me i get back:
{
"data": {
"Aatrox": {
"id": 266,
"title": "the Darkin Blade",
"name": "Aatrox",
"key": "Aatrox"
},
"Thresh": {
"id": 412,
"title": "the Chain Warden",
"name": "Thresh",
"key": "Thresh"
},