Have you experienced a necessity where you want to carry out Google Ads API? If indeed, and considering how might you do it here is a blog for you! Half a month back, one of our engineers had a prerequisite for Google Adwords API joining the Laravel application. Furthermore, looking for a legitimate instructional exercise was a genuine battle! That is the point at which it struck us to concoct an instructional exercise for individual Laravel engineers.
Right away, how about we push forward and perceive how to coordinate Google Adwords API in Laravel App.
Required Package
We will require the accompanying bundles to coordinate Google Adwords API in Laravel App.
google ads/google-promotions PHP
PHP client library for the Google Adwords API.
ext-bcmath
BCMath is a PHP expansion assisting us with float values. BC is known for Binary Calculator in BCMath.
ext-grpc
The system gRPC will be utilized for creating adaptable APIs. It will diminish our battle and permit straightforward client-server correspondence and associated frameworks.
ext-protobuf
The protobuf executes Protocol Buffer of Google for PHP language that upholds serialization of twofold information and incorporates a protoc plugin for creating classes from .proto documents.
Update composer.json with the accompanying bundles
arranger require googleads/google-advertisements php
arranger require ext-bcmath
author require ext-grpc
author require ext-protobuf
Required PHP Extension
Ensure you have the accompanying PHP modules in your framework to coordinate Google Adwords API.
Bcmatch
Groups
Protobuf
Cleanser
Quit looking for the best Laravel designers. Since we are right here!
The vacancy will furnish you with capable and committed engineers with basic and high-level Laravel information. Reach us to recruit a Laravel engineer today!
Create client ID and client secret key
Adhere to these guidelines to produce a client ID and client secret key.
Open the Google API Console Credentials page.
Explore the accompanying way to make an undertaking: Select a venture > NEW PROJECT > Enter the task’s name OR Edit the given project ID. Click Create.
Select Create certifications and snap-on OAuth client ID on the Credentials page.
Whenever provoked for setting the item name on the Consent screen, click Configure assent screen, give the data asked to, and click Save and you will get back to the Credentials screen.
Select the Application type and snap Create
Duplicate your client ID and client mysterious as you will require them for arranging your client library.
Empower Google Ads API
For utilizing the Google Ads API we should empower it. In this way, adhere to these guidelines to empower the Google Adwords API.
Open the Google API Console Credentials page
Explore APIs and Services → Library
Look for Google Ads API
Open the Google Ads API library and empower it
Create Developer Token
Without a designer token, you will not have the option to continue further. With the assistance of the underneath, steps create your engineer token.
Log in to the Google Ads Manager account
Explore TOOLS and SETTINGS > SETUP > API Center. The API Center choice shows up just for Google Ads administrator accounts.
Finish up the structure to demand an engineer token.
Note: Only endorsed designer tokens will be utilized for creation. A non-supported designer token must be utilized with a test account.
Create Refresh Token
Run AuthenticateInDesktopApplication.php or AuthenticateInWebApplication.php in the terminal.
To run any of the above records go-to way for the document and then the PHP filename.
Bring Data involving Google Adwords API in Laravel App
Thus, far we are finished with the underlying task set up and creating an engineer token for utilizing Google Ads API. Presently, how about we do some coding.
Duplicate example google_ads_php.ini to the home registry.
Set google_ads_php.ini way in the application config.
‘google_ads_php_path’ => realpath(base_path(‘google_ads_php.ini’))
Register GoogleAdsClient in AppServiceProvider
use Google\Ads\GoogleAds\Lib\V9\GoogleAdsClientBuilder;
use Google\Ads\GoogleAds\Lib\OAuth2TokenBuilder;
public capacity register()
{
// Ties the Google Ads API client.
$this->app->singleton(‘Google\Ads\GoogleAds\Lib\V9\GoogleAdsClient’, work () {
// Builds a Google Ads API client designed from the properties record.
return (new GoogleAdsClientBuilder())
->fromFile(config(‘app.google_ads_php_path’))
->withOAuth2Credential((new OAuth2TokenBuilder())
->fromFile(config(‘app.google_ads_php_path’))
->construct())
->construct();
});
}
Github Repository: Google Ads API Integration Demo
You can visit the source code: google-advertisements programming interface demo and play around with the code.
End
I trust the instructional exercise on coordinating Google Adwords API in Laravel App was useful to you. Assuming you have any inquiries or ideas go ahead and get in touch with us. For additional instructional exercises, visit the Laravel instructional exercises page where you can clone the storehouse, begin investigating the code and find out about more Laravel.