Yahoo! Search Marketing

Enterprise Web Services: Sample Code

Enterprise Web Services (EWS) and the Marketing API enable you to build client software that interacts with the Yahoo! search marketplace. Read the topics presented here and then use the navigation bar on the left side of the page to view the sample client applications.

Client Applications

The Marketing API utilizes SOAP and WSDL, both of which are supported in a growing number of languages. To help you get started building client applications and/or to ease the process of migrating your existing applications to EWS, we provide source code for a sample client application in these languages: Java, .NET, PHP, Perl, and the Yahoo::Marketing Perl SDK. We also provide sample data for all markets.

Note: To build and run the sample client application, the source code file (executable) and the sample data file must reside in the same directory.

Source Code

Before you begin, please review the contents of the source code file. We have included useful functions for getting and caching the location using the LocationService (see EWS Locations) and SOAP utilities for creating headers and executing commands (see SOAP Basics):

You must update the source code file and insert your EWS sandbox credentials (username, password, license, master account ID, and account ID, market, and locale). The client application will automatically access the sample data file that corresponds to the market that you specify.

Sample Data

Sample data is provided for all supported markets. To ensure that client applications are locally relevant, the sample data provided for non-US markets may differ from the sample data provided for the US market. Note also that some markets, such as Austria (AT) and Germany (DE), share the same sample data.

As shown in the table below, the sample data files are named sample_data_market.properties, where market is the two-letter market code. When you update the source code file to insert your credentials, use the two-letter market code to designate your market.

Note: The CampaignService specifies that campaign names must be unique within an account. The first time you run the client application a campaign named "MP3" (US market sample data) is created (see Basic Tasks). Before you run the application a second time you will need to change the name of the campaign in the sample data file. If you do not do this you will get an error.

Once the client application is up and running, you can modify the sample data to create campaigns, ad groups, ads, and keywords any way you like. Keep in mind, however, that we cannot guarantee that these changes will be preserved in the sandbox.

Country (Market ID) Sample Data
Australia (AU) sample_data_US.properties
Austria (AT) sample_data_DE.properties
Brazil (BR) sample_data_BR.properties
Canada (CA) sample_data_US.properties
Denmark (DK) sample_data_DK.properties
Finland (FI) sample_data_US.properties
France (FR) sample_data_FR.properties
Germany (DE) sample_data_DE.properties
Hong Kong (HK) sample_data_HK.properties
India (IN) sample_data_IN.properties
Italy (IT) sample_data_IT.properties
Japan (JP) sample_data_JP.properties
Korea (KR) sample_data_KR.properties
Latin America and Mexico (MX) sample_data_MX.properties
Netherlands (NL) sample_data_NL.properties
Norway (NO) sample_data_NO.properties
Southeast Asia (SG) sample_data_SG.properties
Spain (ES) sample_data_ES.properties
Sweden (SE) sample_data_SE.properties
Switzerland (CH) sample_data_DE.properties
Taiwan (TW) sample_data_TW.properties
United Kingdom (UK) sample_data_UK.properties
United States (US) sample_data_US.properties

Basic Tasks

The Java, .NET, Perl, Yahoo::Marketing Perl library, and PHP sample client applications all perform the same basic tasks. These tasks are outlined here, using the sample data for the US market as an example.

  1. Create a campaign with these attributes:
    1. Campaign name is "MP3"
    2. sponsoredSearchON, advancedMatchON, and contentMatchON are set to true
    3. campaignOptimizationON is set to false
    4. startDate is set to tomorrow and endDate is set to a year from tomorrow
  2. Under the campaign, create an ad group with these attributes:
    1. Ad group name is "MP3"
    2. contentMatchMaxBid is set to 0.25 and sponsoredSearchMaxBid is set to 0.50
    3. advancedMatchON is set to false (this overrides the setting at the Campaign level)
  3. Under the ad group, create two ads with these attributes:
    1. Ad names are "IPod1" and "IPod2"
    2. Both ads have a title, a short description, a long description, a landing page URL, and a display URL
    3. "IPod2" also uses keyword substitution in the title, short description and long description
  4. Under the ad group, create four keywords with these attributes:
    1. The four keywords are:
      1. "iPod": sponsoredSearchMaxBid is not set (this keyword will inherit the ad group level bid)
      2. "iPod mini": sponsoredSearchMaxBid is set to 0.50
      3. "iPod U2": sponsoredSearchMaxBid is set to 0.25
      4. "iPod Shuffle": sponsoredSearchMaxBid is set to 0.4
    2. For all four keywords, advancedMatchON is set to true
    3. None of the four keywords has a URL override set
    4. None of the four keywords has alternate text

Best Coding Practices

Documentation that describes best coding practices for EWS Version 4+ and Variable Minimum Bids is available on the Technology Solutions Portal (see Downloads).