PHP code example of xp-forge / google-search

1. Go to this page and download the library: Download xp-forge/google-search library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xp-forge / google-search example snippets


use com\google\search\custom\GoogleSearchClient;
use util\cmd\Console;

$client= new GoogleSearchClient('http://gsa23.enterprisedemo-google.com/search');
$response= $client->searchFor((new GoogleSearchQuery())
  ->withTerm('test')
  ->startingAt(10)
);

Console::writeLinef('Searching for "test" took %3.f second(s)', $response->getTime());
Console::writeLine('Results: ', $response->getResultSet());