Pedro Chagas
asked on
Organize data from Google news API using php
Hi E's, I need to organize some data from a query of google news API, and I want to list or organize and put some of that received information into a php array. In this case I want put the publishers of the news into array.
I try this code:
What I do wrong?
The best regards, JC
I try this code:
<?
$jsonString = file_get_contents("https://ajax.googleapis.com/ajax/services/search/news?v=1.0&q=algarve%20turismo&hl=pt&ned=pt-PT_pt&callback=foo");
$json = json_decode($jsonString);
$links = array();
foreach($json->foo as $item) {
$links[] = $item->publisher;
}
?>
<pre>
<?
print_r($links);
?>
But the result is:Warning: Invalid argument supplied for foreach() in /home/pedro/public_html/biblioteca/tutoriais/1140/exemplo.php on line 5
Array
(
)
What I do wrong?
The best regards, JC
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The line has been change to:
Open in new window
The output in the browser is:
Open in new window
The goal is put in php array the "publisher": data/information, but I still do something wrong!Can you see what is wrong in my code?
Regards, JC