Twitter Trends API weekly.json causing error "Cannot use object of type stdClass as array"
- by tucson
I have the following PHP code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result);
foreach ($obj[0]->trends as $trend) echo utf8_decode($trend->name);
which works…