You are here

public function GoogleCSEServices::isAccurateResult in Google Custom Search Engine 8.3

Same name and namespace in other branches
  1. 8.2 src/GoogleCSEServices.php \Drupal\google_cse\GoogleCSEServices::isAccurateResult()

Check Return if the response from Google is accurate.

Google initially estimates the exact number of results that the search should have.

Parameters

string $response: The XML response from Google.

Return value

bool TRUE if the results are considered accurate.

1 call to GoogleCSEServices::isAccurateResult()
GoogleCSEServices::responseResults in src/GoogleCSEServices.php
Function to fetch the results xml from Google.

File

src/GoogleCSEServices.php, line 401

Class

GoogleCSEServices
Additional functions as services for Google CSE.

Namespace

Drupal\google_cse

Code

public function isAccurateResult($response) {
  $accurate = FALSE;

  // Time to get the response.
  $xml = simplexml_load_string($response);

  // And to check the "accurate" Google variable, if the XT flag exists
  // the search is accurate.
  if (isset($xml->RES->XT)) {
    $accurate = TRUE;
  }
  return $accurate;
}