1
I have the following result in JSON and need to treat it with PHP.
JSON:
{
"name": "abc",
"count": 6,
"frequency": "Manual Crawl",
"version": 3,
"newdata": true,
"lastrunstatus": "success",
"thisversionstatus": "success",
"thisversionrun": "Thu Jul 09 2015 11:46:39 GMT+0000 (UTC)",
"results": {
"collection2": [
{
"property11": {
"href": "http://click.uol.com.br/?rf=meio-ambiente_home-headline-especiais-2colunas-1_1&u=http://noticias.uol.com.br/meio-ambiente/ultimas-noticias/redacao/2015/07/08/lei-mexicana-faz-com-que-tigres-e-leoes-sejam-vendidos-a-preco-de-banana.htm",
"text": "Lei mexicana faz com que tigres e leões sejam vendidos a \"preço de banana\""
}
},
PHP:
<?php
$request = "https://www.kimonolabs.com/api/5bwvka8s?apikey=*****&kimmodify=1";
$response = file_get_contents($request);
$results = json_decode($response, TRUE);
foreach($results['results']['collection2'] as $collection) {
echo "<a href='" . $collection['property11']['href'] ."'>" . $collection['property11']['text'] . "</a><br >";
}
?>
Problem solved!
You could post your full json?
– Ricardo
Shouldn’t be
echo
of$results
instead of$response
?– Sergio
I tested here and gave anyway, appears all data JSON. #@Sergio
– GustavoCave
What gives
var_dump($results);
?– Sergio
collection2 is a vector, $Results['Results']['collection2'][0]['property11']['text']
– Hiago Souza
@Gustavocave ask the question the result of
echo
and also of avar_dump
of the variable$response
. So help in the answers...– KaduAmaral
I got through the answer below Hiago . I thank you all!
– GustavoCave