Skip to content

Commit

Permalink
decode widgets into an Object
Browse files Browse the repository at this point in the history
  • Loading branch information
x-fran committed Feb 29, 2020
1 parent 269ffe2 commit dcdf95d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Google/GTrends.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,16 @@ public function interestOverTime($kWord, $category=0, $time='now 4-H', $property
$data = $this->_getData(self::GENERAL_ENDPOINT, 'GET', $payload);
if ($data) {

$widgetsArray = Json\Json::decode(trim(substr($data, 4)), Json\Json::TYPE_ARRAY)['widgets'];
$widgets = Json\Json::decode(trim(substr($data, 4)), Json\Json::TYPE_OBJECT)->widgets;

foreach ($widgetsArray as $widget) {
foreach ($widgets as $widget) {

if ($widget['id'] == 'TIMESERIES') {
if ($widget->id == 'TIMESERIES') {

$interestOverTimePayload['hl'] = $this->options['hl'];
$interestOverTimePayload['tz'] = $this->options['tz'];
$interestOverTimePayload['req'] = Json\Json::encode($widget['request']);
$interestOverTimePayload['token'] = $widget['token'];
$interestOverTimePayload['req'] = Json\Json::encode($widget->request);
$interestOverTimePayload['token'] = $widget->token;

$data = $this->_getData(self::INTEREST_OVER_TIME_ENDPOINT, 'GET', $interestOverTimePayload);
if ($data) {
Expand Down

0 comments on commit dcdf95d

Please sign in to comment.