Closed mehulvadodariya2012 closed 5 years ago
You can add DFSClient to the laravel service provider as singlton. This may help. If it doesn't I will roll out the laravel version today.
Same error getting with laravel service provider
It is working solution. You can use it. Full version for laravel will be provide today.
AppServiceProvider
namespace App\Providers;
use DFSClient\DFSClient;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$GLOBALS['DFSClient'] = new DFSClient('your login', 'your password');
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
}
}
Controller
public function demo ()
{
$model = new RelatedKeywords();
$completed = $model->setOpt('keyword','big data')
->setOpt('language', 'en')
->setOpt('country_code', 'US')
->setOpt('depth', 2)
->get();
if (!$completed->isSuccessFul())
dd($completed);
dd($completed);
// you can call property as described below
echo 'status: ' .$completed->status ."<br>";
echo 'results_time: ' .$completed->results_time ."<br>";
echo 'results_count: '.$completed->results_count ."<br>";
foreach ($completed as $key=>$item) {
dump($item);
}
}
Also, when you use tasks. You must call getAfterMerge. example:
$model = new SettingTasks();
$pool[] = $model::setOpt('site', 'ranksonic.com')->setOpt('crawl_max_pages', 10);
//$pool[] = $model::setOpt('site', 'ranksonic.com')->setOpt('crawl_max_pages', 10); -if it will be uncommented, script will send 2 tasks
$completed = SettingTasks::getAfterMerge($pool);
if (!$completed->isSuccessful())
dd($completed);
foreach ($completed as $key=>$item){
dump($item);
What is the use of getAfterMerge method?
Thanks you
Guys, sorry for re-open the issue, but how to install version for laravel ? composer require "jovixv/dataforseo_client:v1.0.1-laravel" is not working, but i see this version in "Releases". Also, is it possible to not use $GLOBALS for DFSClient ? Can i just construct it without a need to put it in AppService provider. It will make it more flexible. I want to configure it on a fly and there is no need to put it in AppServiceProvider. Example: $DFSClient = new DFSClient('Your Login','Your Password'); $model = new SettingSerpTasks();
Hi Team I am developing with laravel 5.6 PHP7.1
Error Screenshot
Code Screenshot