This is the Merjis AdWords Toolkit for OCaml.
Amongst the features that this toolkit offers:
Find out more about the Google AdWords API.
The library is licensed under the GNU LGPL with OCaml linking exception. The programs are licensed under the GNU GPL. This program comes with ABSOLUTELY NO WARRANTY OR SUPPORT.
For API version 8, use adwords-api-2.8.1.tar.gz (about 67K). This version requires OC-SOAP version 0.7.0.
For API version 7, use adwords-api-2.7.0.tar.gz (about 66K). This version requires OC-SOAP version 0.7.0.
For API version 6, use adwords-api-2.6.0.tar.gz (about 66K). This version requires OC-SOAP version 0.6.1.
For API version 5, use adwords-api-2.5.2.tar.gz (about 64K). This version requires OC-SOAP version 0.6.1.
Documentation and examples are included in the files.
./campaign.opt language_target 'My Campaign' 'en' 'fr'
./campaign.opt copy 'My Campaign' 'My New Campaign'
./keyword.opt create 'My Campaign' 'My AdGroup' 'holidays/broad' 'holidays/exact'
./creative.opt update_all 'My Campaign' 'My AdGroup' headline 'Cheap Flights'
etc.
ledit ./adwords
Objective Caml version 3.08.2
# getAllAdWordsCampaigns campaign_svc 0l;;
[ all your campaigns will be listed out ]
#!/usr/bin/ocamlrun ocaml #use "adwords.init" open Printf let campaigns = getAllAdwordsCampaigns campaign_svc 0l ;; List.iter (fun campaign -> printf "%d %s\n" campaign.campaign_id (Option.get campaign.campaign_name) );;
Save the above into a file, chmod +x and run it directly as a script.
All your API usage is checked, unobtrusively, for type safety:
# addKeywordList ;;
- : Adwords_data.keyword_data OCSoap.service ->
Int32.t ->
KeywordService_types.keyword list ->
KeywordService_types.keyword list = <fun>
# addKeywordList keyword_svc 14567l "foo";;
This expression has type string but is here used with type
KeywordService_types.keyword list
For more details, see the Adwords API reference documentation.
We recommend that you start with an Ubuntu or Debian system. While it is theoretically possible to get this working on Windows or Mac OS X, these proprietary systems don't have packaging systems or even in some cases compilers, making the whole installation needlessly difficult. If you're still stuck with Windows, we suggest installing CoLinux or even CoLinux+Ubuntu under Windows.
Install the base OCaml packages:
sudo apt-get install ocaml ocaml-native-compilers libcalendar-ocaml-dev \ libequeue-ocaml-dev libextlib-ocaml-dev libnetclient-ocaml-dev \ libpcre-ocaml-dev libpxp-ocaml-dev libocamlnet-ocaml-dev cduce ledit
Note: cduce doesn't come with Ubuntu Hoary release, but it is standard in the current 6.06 LTS release.
Download and compile our CSV and OC-SOAP libraries:
tar zxf ocaml-csv-1.X.Y.tar.gz cd ocaml-csv-1.X.Y #comment: edit Makefile.config if necessary make cd .. tar zxf ocsoap-0.X.Y.tar.gz cd ocsoap-0.X.Y #comment: edit Makefile.config if necessary make cd ..
Download and compile the Adwords API code:
tar zxf adwords-api-2.X.Y.tar.gz cd adwords-api-2.X.Y #comment: edit Makefile.config to set the paths to the CSV and OC-SOAP libs make
Optional step: Google periodically changes their WSDL files. You can make sure you have the latest version by doing this command. You will need wget installed for this to work.
make download_google_wsdl && make
Install and run stunnel:
sudo apt-get install stunnel sudo stunnel -c -d 8081 -r adwords.google.com:https
You only need to do this once after the machine reboots. You can put the 'sudo stunnel' line in your start-up scripts.
Create a file ~/.adwordsapidata which will contain your username, password, etc. The file should have the following format:
email your AdWords login email address password your password developer-token your AdWords API developer token client your MCC client email address (optional) application-token your AdWords API application token (optional)
Try it out!
./adwords
Objective Caml version 3.08.2
# List.hd (getAllAdWordsCampaigns campaign_svc 0l);;
- : CampaignService_types.campaign =
{campaign_id = 5124420l; campaign_name = Some "XXX";
campaign_status = Some `Deleted; campaign_startDate = Some <abstr>;
campaign_endDate = Some <abstr>; campaign_dailyBudget = 250000000L;
campaign_optInSearchNetwork = Some true;
campaign_optInContentNetwork = Some true;
campaign_campaignNegativeKeywords =
[ etc ]
If you have any problems, please contact rich@merjis.com.
effective marketing for the web
Merjis specialises in innovative marketing,
accessibility, search engine optimisation (SEO),
and development for the web.