x-fran / g-trends

Google Trends API for PHP
https://tarlabs.es
MIT License
113 stars 47 forks source link

interestOverTime as a array #5

Closed iialexeyii closed 6 years ago

iialexeyii commented 6 years ago

Hello Please add that code to your repository That code adds to your method compare function

public function interestOverTime($kWord, $category=0, $time='now 1-H', $property='') { if(gettype($kWord) == 'array'){ if (count($kWord) == 0 OR count($kWord) > 5) {

            throw new \Exception('Invalid number of items provided in keyWordList');
        }

        $comparisonItem = [];
        foreach ($kWord as $kWordItem) {

            $comparisonItem[] = ['keyword' => $kWordItem, 'geo' => $this->options['geo'], 'time' => $time];
        }
    }else{
        $comparisonItem[] = ['keyword' => $kWord, 'geo' => $this->options['geo'], 'time' => $time];
    }

    $payload = [
        'hl' => $this->options['hl'],
        'tz' => $this->options['tz'],
        'req' => Json\Json::encode(['comparisonItem' => $comparisonItem, 'category' => $category, 'property' => $property]),
    ];