Google Adwords API – Part 1
Google offers a lot of different services. Some of them have their own API to read data from external programs. One of them is AdWords.
AdWords uses SOAP interfaces to get data from campaigns and other things, but if you already worked with SOAP, this can be a hard job. For this you have a very good knowledge of the interface itself. The other problem is, that the API gets updates nearly every half year, so things can change. New values, deprecated values, …
If you do not have the time to study this interfaces, you may need the Client Library from Google. You can find the PHP Version here.
Adwords client library
One advantage of the library is, that you can get data much easier. The library has many examples of how to use special services and how to correctly use it. It is also discussed in many blogs and forums.
Very simple, you only need to download it and unzip it somewhere. You can easily use it from code.
How to work with the interface
If you want to use the PHP AdWords library, you have to include the AdWordsUser.php on top of your PHP file:
Then you need to create a AdWordsUser object:
$user = new AdWordsUser(null, $adwords_username, $adwords_password, $adwords_developerToken);
An AdWordsUser object needs some values. These are:
- AdWords username
The username of your Google account, for which you registered your AdWords.
- Adwords Passwort
The password you set for the Google account.
- Adwords developer token
A developer token which can be ordered here.
If your AdWords account is a so called MCC account, than there may be different AdWords account combined into one login. You can say that this is a top account to get data from multiple accounts with only one username and password (for example for customers of marketing and web agency).
Now we can connect with a registered account. For this we use the AdWords ID, which is unique for each AdWords account. You can find it on your Google AdWords user interface after login on the right top border. It looks like: XXX-XXX-XXXX. We copy this number into our code (without ‘-‘):
//set Adwords Client Id
You have now a ready configured user object. You can use it to get data from AdWords.
This was the first part. In the next part we start getting data from Google.