Using the Adwords API PHP Library with Laravel 4

1,665 views
Skip to first unread message

Sunny Rangnani

unread,
Dec 4, 2014, 11:59:41 AM12/4/14
to adwor...@googlegroups.com
Hi There,

Since laravel is getting quite popular i thought i use it with the adwords API for my next project. I was able to link the google api for Analytics, etc quite easily but when it came to adwords i keep getting 'Class AdwordsUser does not exist'. I have already added ""googleads/googleads-php-lib": "dev-master" to the composer.json file of my project and ran composer update, which downloaded the library to my vendor folder with the path 'vendor\googleads\googleads-php-lib\src\Google\Api\Ads\AdWords'.

My code for the controller is
public function __construct(AdwordsUser $user){
$this->user = $user;
$this->user->SetOAuth2Info(array(
'client_id'=>Config::get('api.google_client_id'), 
'client_secret'=>Config::get('api.google_client_secret')));
   
}
 
Any ideas ? I am hoping if we can figure this out a public documentation could be made of it so similar frameworks like cakephp, etc could also make use of it.

Danial Klimkin

unread,
Dec 11, 2014, 2:19:21 PM12/11/14
to adwor...@googlegroups.com
Hello Sunny,


We do not officially support laravel currently unfortunately.

Please let us know if you were able to identify an issue and there are any library changes required to improve support.


-Danial, AdWords API Team.
Message has been deleted

Sunny Rangnani

unread,
Dec 17, 2014, 11:32:19 AM12/17/14
to adwor...@googlegroups.com
Hi Danial,

Thank you for the prompt reply, and no i do not believe any modifications are required to the API at this moment. I did get it working and i will lay out my steps below so it helps others out as well. the following steps will help in installing the API onto various php frameworks like cakePHP, Laravel, etc.

1. Add the following line to your composer.json file under 'require'. This file can be found in the root directory of your laravel installation.
"googleads/googleads-php-lib": "dev-master"

2. Using cmd on your windows or a terminal on a mac, navigate to your Laravel installation and run the following commands.
composer update
composer
dump-autoload

3. Now to use the laravel src files, refer to autoload.php in the bootstrap folder of your Laravel installation. This should list all classes that you may need for your project. For instance, to create a new user instance in your construct, you could use the following code:
public function __construct(AdWordsUser $user){
$this->user = $user;
$this->user->SetUserAgent('');
$this->user->SetClientLibraryUserAgent('');
$this->user->SetDeveloperToken(Config::get('');
}

The methods i have used above can be found by exploring the adwords api itself.

If you have still have trouble, feel free to reply here and i will do my best to help.



Jiwan Ghosal

unread,
Mar 23, 2015, 6:58:05 AM3/23/15
to adwor...@googlegroups.com

hi sunny,
I am very new to laravel and adword api so could you tell me how to include and extract all campaigns in pagesColtroller.

Thanks & regards
jiwan ghosal 

Alex Mansour

unread,
May 1, 2015, 9:07:18 AM5/1/15
to adwor...@googlegroups.com
Hello Sunny, 

I'm using Laravel 4.2 and I want to retrieve basic Campaign information such as Cost, Impressions, Clicks, Conversions. I have search the web for any Laravel bundles with no luck. Also I installed the google AdWords client library, could you point me how to get user Campaign info?

Also from Google API Console I couldn't find any related AdWords web services.

Thanks in advance.

va...@trafficpoint.io

unread,
Nov 17, 2015, 9:07:18 AM11/17/15
to AdWords API Forum
Did you ever ended up using Laravel 5 with this API
can you share your usage


On Wednesday, December 17, 2014 at 6:32:19 PM UTC+2, Sunny Rangnani wrote:

Nikolaj Petersen

unread,
Dec 17, 2015, 8:57:48 AM12/17/15
to AdWords API Forum
Reply all
Reply to author
Forward
0 new messages