How to implement Google Adwords Soap Call using pure java

In this example you will see step-by-step instructions of how to create a java program without frameworks, using pure Java to extract data from your campaign. I assume that you have a campaign configured in your Google Adwords account. I recommend, before you read this paper, to take a look at the following link:

https://developers.google.com/adwords/api/docs/guides/basic-concepts?hl=en.

It’s about how the Adwords Api flow and how it was implemented.

To program Adwords call follow the step-by-step below.

1.- Proxy Config:

Java Proxy Config
First, if you need, I configure the proxy in pure java. You need to use System.setProperty to set the follow properties: https.proxyHost, https.proxyPort, http.proxyUser, http.proxyPassword, jsse.enableSNIExtension.

2.- Authorization:

authorization
In this step, I get authorization using the following entities: client_id, client_secret, refresh_token, grant_type (building post parameters).

3.- Build Adwords Query:

buildAdwordsQuery
Then I set up the query that I will submit from Google Adwords.

4.- Executing query:

In this step we set information as below in the Http Header. One of the most important information is the authorization token refresh in step 2. Beyond the http header data, we need to configure the SOAP envelope, Body and Header. In the Header (RequestHeader) I set the clientCustomerId, developerToken and userAgent. The Body part must be configured depending on which query you want to run, in this case I user the CampaignServiceSoapBinding address location https://adwords.google.com/api/adwords/cm/v201506/CampaignService, operation get.

Executing1Executing2

Below the complete Code:

https://github.com/zurdosp/repo1/blob/master/AdWordsGetData

I hope I have helped you.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s