Closed shindesgaar077 closed 7 years ago
hi @shindesgaar077
Did you run composer install and register the provider? Also it's easier for me to help you, if you include a pastebin or picture of your code
yes i was run composer . i can use laravel 5.4 version and use in localhost run example using laravel
1)TestController.php <?php
namespace App\Http\Controllers;
use App\Classes\Service;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class TestController extends BaseController
{
public function index(){
$Service= new Service();
$Service->campaigns();
}
}
2)service class
<?php
namespace App\Classes;
use LaravelGoogleAds\Services\AdWordsService; use Google\AdsApi\AdWords\AdWordsServices; use Google\AdsApi\AdWords\AdWordsSessionBuilder; use Google\AdsApi\AdWords\v201609\cm\CampaignService; use Google\AdsApi\AdWords\v201609\cm\OrderBy; use Google\AdsApi\AdWords\v201609\cm\Paging; use Google\AdsApi\AdWords\v201609\cm\Selector;
class Service { /* @var AdWordsService / protected $adWordsService;
/**
* @param AdWordsService $adWordsService
*/
public function __construct(AdWordsService $adWordsService)
{
$this->adWordsService = $adWordsService;
}
public function campaigns()
{
$customerClientId = '104-546-6436';
$campaignService = $this->adWordsService->getService(CampaignService::class, $customerClientId);
// Create selector.
$selector = new Selector();
$selector->setFields(array('Id', 'Name'));
$selector->setOrdering(array(new OrderBy('Name', 'ASCENDING')));
// Create paging controls.
$selector->setPaging(new Paging(0, 100));
// Make the get request.
$page = $campaignService->get($selector);
echo $page;
}
}
Please use a service such as pastebin or gist for your code examples. Whats the value of $this->adWordsService?
in eaxmple use as it's
i can use in example in laravel ...localhost cerated on controller and one class files and call them but its not working
i dont know what value need to $this->adWordsService?
I'm sorry, but the question is too unclear for me to help you.
sir i want get all campaigns data using laravel .please help me ...;please give me example code to execution
After you completed installation and setup (obtaining a token etc.) you'll have to inject the LaravelGoogleAds\Services\AdWordsService
into your controller/service/helper/(..).
Your exception clearly states that the AdWordsService doesn't get injected - you have to debug the reason for this. Thats why I asked you for the value of $this->adWordsService.
Good luck
sit i cat use pastbin url is 1)Controller https://pastebin.com/A7vQwYRu crated Object OF service Class
2)Class https://pastebin.com/Z8GUSriC
but get errror
Argument 1 passed to App\Classes\Service::__construct() must be an instance of LaravelGoogleAds\Services\AdWordsService, none given, called in C:\xampp\htdocs\test_laravel_project\app\Http\Controllers\TestController.php on line 16 and defined
please healp me
Hi @shindesgaar077
You need to inject the service using the service locator. You can read more about the service locator here https://laravel.com/docs/5.4/container
If you have further questions to dependency injection or other topics unrelated to this package, then please post them on stackoverflow.com.
Argument 1 passed to App\Classes\Service::__construct() must be an instance of LaravelGoogleAds\Services\AdWordsService, none given, called in C:\xampp\htdocs\test_laravel_project\app\Http\Controllers\TestController.php on line 16 and defined