x-fran / g-trends

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

Decoding failed: Syntax error #28

Closed DrLightman closed 4 years ago

DrLightman commented 4 years ago

Hello, getting this message upon this kind of request for getDailySearchTrends:

$hl = "en-ZW";
$tz = 60;
$geo = "ZW";

Originated in this block:

try {
    $dataJson = $this->_getData(self::DAILY_SEARCH_TRENDS_ENDPOINT, 'GET', $params);
    return Json\Json::decode(trim(substr($dataJson, 5)), Json\Json::TYPE_ARRAY);
} catch (\Exception $e) {
    die($e->getMessage());
}

Not sure why it happens, but it looks like when the returned $dataJson is FALSE for whatever the reason, the app literally dies. Couldn't be falsy returned instead?

x-fran commented 4 years ago

I suppose yes, can be a good idea to return false instead of die(). I will take it in consideration. Thank you.