x-fran / g-trends

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

Call to undefined method Google\GTrends::relatedQueries #37

Closed ryankaka92 closed 3 years ago

ryankaka92 commented 3 years ago
<?php 

include __DIR__.'/vendor/autoload.php';

use Google\GTrends;

# This options are by default if none provided
$options = [
        'hl'  => 'en-US',
        'tz'  => -60, # last hour
        'geo' => 'IE',
    ];
$gt = new GTrends($options);

print_r( $gt->relatedQueries(['games']));

Hey guys did I make a mistake? I installed with composer;

It gives this error: `PHP Fatal error: Uncaught Error: Call to undefined method Google\GTrends::relatedQueries() in /root/gtrends/get.php:17 Stack trace:

0 {main}

thrown in /root/gtrends/get.php on line 17`

DrLightman commented 3 years ago

Where did you get the "relatedQueries()" method?

You can see a list of supported methods in this file:

/vendor/x-fran/g-trends/index.php

ryankaka92 commented 3 years ago

Hello I got it here:

https://github.com/x-fran/g-trends#related-queries

ryankaka92 commented 3 years ago

It seems like its getRelatedSearchQueries not relatedQueries please fix it on the homepage.

use Google\GTrends;

# This options are by default if none provided
$options = [
        'hl'  => 'en-US',
        'tz'  => -60, # last hour
        'geo' => 'US',
    ];
$gt = new GTrends($options);

print_r( $gt->getRelatedSearchQueries(['unscramble'],0, 'today 3-m') );

Also if I may ask Is this the correct way to get the data for last 4 hours? It doesnt work with 2-d 4-h, 1-h.

It works with longer than 6m

Thank you very much for responding.

x-fran commented 3 years ago

Just pushed a fix for getRelatedSearchQueries. Here an example for one hour: gt->getRelatedSearchQueries(['Donald Trump'], 0, 'now 4-H')