PHP code example of zanysoft / laravel-serpapi
1. Go to this page and download the library: Download zanysoft/laravel-serpapi 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/ */
zanysoft / laravel-serpapi example snippets
return [
'api_key' => env('SERPAPI_API_KEY'),
'search_engine' => env('SERPAPI_ENGINE', 'google')
];
use ZanySoft\LaravelSerpApi\Facades\SerpApi;
$client = SerpApi::GoogleSearch();
$query = ["q" => "coffee","location"=>"Austin,Texas"];
$response = $client->get_json($query);
print_r($response)
use ZanySoft\LaravelSerpApi\Facades\SerpApi;
$client = SerpApi::GoogleSearch();
$query = [
"q" => "query",
"google_domain" => "Google Domain",
"location" => "Location Requested",
"device" => "device",
"hl" => "Google UI Language",
"gl" => "Google Country",
"safe" => "Safe Search Flag",
"num" => "Number of Results",
"start" => "Pagination Offset",
"serp_api_key" => "Your SERP API Key",
"tbm" => "nws|isch|shop"
"tbs" => "custom to be search criteria"
"async" => true|false # allow async
];
$html_results = $client->get_html($query);
$json_results = $client->get_json($query);
use ZanySoft\LaravelSerpApi\Facades\SerpApi;
$client = SerpApi::GoogleSearch();
$location_list = $client->get_location('Austin', 3);
print_r($location_list);
[{:id=>"585069bdee19ad271e9bc072",
:google_id=>200635,
:google_parent_id=>21176,
:name=>"Austin, TX",
:canonical_name=>"Austin,TX,Texas,United States",
:country_code=>"US",
:target_type=>"DMA Region",
:reach=>5560000,
:gps=>[-97.7430608, 30.267153],
:keys=>["austin", "tx", "texas", "united", "states"]},
...]
use ZanySoft\LaravelSerpApi\Facades\SerpApi;
$client = SerpApi::GoogleSearch();
$info = $client->get_account();
print_r($info);
use ZanySoft\LaravelSerpApi\Facades\SerpApi;
$client = SerpApi::GoogleSearch();
$data = $client->get_json([
'q' => "Coffee",
'tbm' => 'isch'
]);
foreach($data->images_results as $image_result) {
print_r($image_result->original);
}
bash
php artisan vendor:publish --provider="ZanySoft\LaravelSerpApi\SerpApiServiceProvider" --tag="serpapi-config"