i have created a block and try to feed it with WS request
function amu_news_preprocess_block(&$variables)
{
if ($variables['elements']['#configuration']['id'] == 'amu_news_block') {
$client = new GuzzleHttpClient();
$url = 'mywebserviceretrievingjson.org';
$response = $client->request('GET', $url);
//this display json:
$content = $response->getBody()->getContents();
// this generate server error although $content contains array of nodes as expected:
// $content=json_decode($response->getBody()->getContents(),true);
$variables['elements']['content'] = $content;
//why do i need to do that next line ? i dunno but this makes json content display on my twig template:
$variables['content'] = $variables['elements']['content'];
}
}
i am trying to display feeds as array or object