Open avesgit opened 7 years ago
Sorry for being late.
Publish the config from command line
php artisan vendor:publish --provider="JanDrda\LaravelGoogleCustomSearchEngine\LaravelGoogleCustomSearchEngineProvider"
Get all configuration values as described in README and save it https://github.com/jdrda/laravel-google-custom-search-engine#configuration
In your controller map the namespace with use:
use JanDrda\LaravelGoogleCustomSearchEngine\LaravelGoogleCustomSearchEngine;
Use in you controller like described in README https://github.com/jdrda/laravel-google-custom-search-engine#usage
So example controller will be:
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use JanDrda\LaravelGoogleCustomSearchEngine\LaravelGoogleCustomSearchEngine;
class GoogleSearchController extends Controller
{
public function index(){
$fulltext = new LaravelGoogleCustomSearchEngine(); // initialize
$results = $fulltext->getResults('some phrase'); // get first 10 results for query 'some phrase'
}
}
Is it clear?
i am getting an empty array in result in laravel 5.2
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use JanDrda\LaravelGoogleCustomSearchEngine\LaravelGoogleCustomSearchEngine;
class SearchController extends Controller
{
public function index(){
$fulltext = new LaravelGoogleCustomSearchEngine(); // initialize
$results = $fulltext->getResults('facebook'); // get first 10 results for query 'some phrase'
echo "<pre>"print_r($results);
}
}
i have same problem, empty array in results in laravel 5.4 @jdrda
could you please give example with view ?
I have also same problem getting result 0 here is object.
{#584 ▼
+"searchTime": 0.175679
+"formattedSearchTime": "0.18"
+"totalResults": "0"
+"formattedTotalResults": "0"
}
How to fix this .
With this js code , i am getting result
(function() {
var cx = '017660551690868778841:usjd0spoeoe';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
I try use in laravel 5.1
Use provider JanDrda\LaravelGoogleCustomSearchEngine\LaravelGoogleCustomSearchEngineProvider::class, alias 'GoogleCseSearch' => JanDrda\LaravelGoogleCustomSearchEngine\Facades\LaravelGoogleCustomSearchEngineProvider::class,
but then i dont know what to do