neosaleem / seostats

Automatically exported from code.google.com/p/seostats
0 stars 0 forks source link

Getting Error When Google has no URLs for a given URL #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Which method(/function) produce a problem?
1.SEOstats_Google::googleTotal2

Does the method(/function) produce the problem for all given URL's?
(If not, what specific URL produces the problem?)
1. http://www.dsero.com or any other URL that is not indexed yet in Google

Please provide any additional information below:
The error is:
<b>Notice</b>:  Undefined property: stdClass::$estimatedResultCount in 
<b>/home/webuser/helloworld/htdocs/stat/seostats.google.php</b> on line 
<b>29</b><br />

The proposed fix is:
public static function googleTotal2($query)
{
    $url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=1&q='.$query;
    $str = SEOstats::cURL($url);
    $data= json_decode($str);
    if (!isset($data->responseData->cursor->estimatedResultCount)){
        return 0;
    }
    return intval($data->responseData->cursor->estimatedResultCount);
}

Original issue reported on code.google.com by mokp...@gmail.com on 1 Aug 2011 at 9:26

GoogleCodeExporter commented 9 years ago
The response from Google is:
{"responseData": 
{"results":[],"cursor":{"moreResultsUrl":"http://www.google.com/search?oe\u003du
tf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den\u00
26q\u003dsite:http://www.dsero.com"}}, "responseDetails": null, 
"responseStatus": 200}

for: 
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=1&q=site:http://ww
w.dsero.com

Original comment by mokp...@gmail.com on 1 Aug 2011 at 9:27

GoogleCodeExporter commented 9 years ago
Thanks for notification! Will fix that..

Original comment by eyecatchup@gmail.com on 2 Aug 2011 at 10:43

GoogleCodeExporter commented 9 years ago
Implemented in GitHub repo.

Original comment by eyecatchup@gmail.com on 4 Aug 2011 at 1:42