Hi, I'm having a bit of discrepency with the results that Google returns in it's API. Say for example I do a search using the api for matches intitle with the phrase "internet marketing system" e.g: function google_results_intitle() { //Function: Returns array of total google matches within website title set_time_limit(1000); $receivedError=0; $maxErrorsAllowed=5; $gs = new GoogleSearch(); $gs->setKey($this->goog_key); $gs->setMaxResults(1); //$gs->setSafeSearch(true); foreach($this->preped_keywords as $key=>$val){ /* * We're using a do/while loop to counter the problem * of http header errors */ $gs->setQueryString("intitle:\"$val\""); do{ $search_result = $gs->doSearch(); ##do the search if($gs->getError()){ $receivedError++; ##increment error count sleep(5); ##sleep script for 5 seconds }else{ $receivedError=0; ##reset error count } //end if } while ( $receivedError && ($receivedError <= $maxErrorsAllowed)); $search[$val] = $search_result->result[estimatedTotalResultsCount]; } //end foreach return $search; /*if(!$search_result){ if($err = $gs->getError()){ return "Couldn't retrieve result"; //echo "<br>Error: " . $err; //exit("<br>Exiting..."); } //end if } else { return $search_result->result[estimatedTotalResultsCount]; } //end if*/ } //end function PHP: I get 122 matches BUT if I repeat this in the Google search bar: "intitle:internet marketing system" I get 1,200,000 results - this is a massive difference in results. Am I doing something wrong? Thanks in advance
Googles results vary wildly depending on the datacenter they decide to use. Nothing you can do about it. In your case I expect there is some kind of bug as the results seem way off. Do other searches come up OK?
Hi, thanks for your reply. Yes all the results appear fine. Although, when I do a generic search for the keyword the results appear in the millions. Can you see anything wrong with the code? SafeSearch and filtering are both off.