Yahoo! Search Marketing

YSM Yahoo! Group Discussions

View All

YSM Blog Posts

Enjoy the Silence (While You Can)
Tue, 24 Nov 2009 19:15:31 +0000

Breaking News from Yahoo! News
Fri, 20 Nov 2009 00:47:21 +0000

You’re Invited…
Tue, 17 Nov 2009 20:03:16 +0000

Anti-Phishing Reminders
Mon, 16 Nov 2009 20:56:48 +0000

One Shining Moment
Thu, 12 Nov 2009 18:28:28 +0000

View All

Sample Code: PHP Client Application

To access Enterprise Web Services (EWS) using the sample PHP client application, follow these instructions.

Environment

To set up your PHP environment, perform these tasks:

1. Install PHP 5.1.2 or higher.

2. Install PHP mbstring module.

3. Enable the PHP soap extension.

  • Windows: add "extension=<ext-dir>/php_soap.dll" to php.ini
  • Unix: add "extension=<ext-dir>/soap.so" to php.ini

4. Enable the PHP SSL extension.

  • Windows: add "extension=extension=<ext-dir>/php_openssl.dll" to php.ini
  • Unix: use php with ssl compiled in.

Note: Contact your system administrator if you need help setting up your PHP environment.

Source Code and Sample Data

For PHP, the source code and sample data includes:

Build and Run

To build and run the PHP client application run through the folowing steps:

1. Download YahooEWSClient.php and sample data properties files (sample_data_*.properties), and save them to your local directory.

2. Edit YahooEWSClient.php to contain your EWS credentials, which are defined near the top of the file:

  • USERNAME
  • PASSWORD
  • MASTER_ACCOUNT_ID
  • ACCOUNT_ID
  • LICENSE
  • MARKET

3. Run the application using this command:

prompt> php -f YahooEWSClient.php

Known Issues

The Marketing API represents the following ID elements as 64 bit long values:

  • The paymentMethodID used in AccountService and UserManagementService.
  • The IDs for the Ad, AdGroup, Campaign, ExcludedWord, and Keyword data objects.

The PHP language does not support the 64 bit long data type. The maximum integer value in PHP is 2147483647. This limitation can cause PHP applications to generate bad requests if the ID element is larger than 2147483647.

Please consider the following rules when writing PHP applications for EWS.

1. When the ID is represented as a string variable, cast it to float to ensure that values larger than 2147483647 are handled correctly. For example:

	$wsdl="https://sandbox.marketing.ews.yahooapis.com/services/V5/CampaignService?wsdl";

	$client = new SoapClient($wsdl, ...);

	$ID = "9999999999999"; // BAD. Generates request with campaignID 2147483647

	$ID = (float) "9999999999999"; // Safe.

	$params = array('campaignID' => $ID);

	$client->__SoapCall('getCampaign', array($params));
;

2. When the ID is represented as a numeric variable, the PHP runtime automatically casts large values to float. Hence, the following is safe:

  $wsdl="https://sandbox.marketing.ews.yahooapis.com/services/V5/CampaignService?wsdl";
  
  $client = new SoapClient($wsdl, ...)
  
  $ID = 9999999999999; // Safe
  
  $params = array('campaignID' => $ID);
  
  $client->__SoapCall('getCampaign', array($params));