Loading ...
Sorry, an error occurred while loading the content.

1150Re: BasicReportService

Expand Messages
  • labtrax
    Jan 13, 2011
    • 0 Attachment
      Hello,

      got it myself. It's kind of sticky (google adwords api is a bit more convenient ;)
      My aim was to get the cost summary per account. So here is what I've done to achieve this:

      Yahoo Java client version downloaded date 2011-01-12

      1. Changes for ewsconfig.properties file:
      # Whether to query and use endpoint from LocationService
      useEndpointFromLocationService=true

      # The end point of the EWS Web Services
      location_service_endpoint=global.marketing.ews.yahooapis.com

      and login data. Remind you need an account able to connect to the api.

      2. Added
      public BasicReportService getReportService() throws Exception{
      return(BasicReportService)getAxisClientService(BasicReportService.class);
      }
      to ServiceLocator.java


      3. Here the java client code for getting a AccountSummaryByDay report
      import java.util.Calendar;
      import java.util.Locale;
      import org.joda.time.DateTime;
      import com.yahoo.sm.ws.client.BasicReportRequest;
      import com.yahoo.sm.ws.client.BasicReportService;
      import com.yahoo.sm.ws.client.BasicReportType;
      import com.yahoo.sm.ws.client.FileOutputFormat;
      import com.yahoo.sm.ws.client.FileOutputType;
      import com.yahoo.sm.ws.client.helper.EWSConfigurator;
      import com.yahoo.sm.ws.client.helper.EWSUtil;
      import com.yahoo.sm.ws.client.helper.ServiceLocator;

      public class Application {

      private static EWSConfigurator ewsConfigurator = EWSConfigurator.getInstance();
      private static ServiceLocator serviceLocator = ServiceLocator.getInstance();
      private static BasicReportService basicReportService = null;

      public static void main(String[] args) throws Exception {

      EWSUtil.setDEBUG(true);
      BasicReportRequest basicReportRequest = new BasicReportRequest();
      basicReportRequest.setReportType(BasicReportType.AccountSummaryByDay);
      basicReportRequest.setStartDate(new DateTime(2011, 1, 10, 0, 0, 0, 0).toCalendar(Locale.GERMANY));
      basicReportRequest.setEndDate(Calendar.getInstance());
      basicReportRequest.setReportName("test");
      basicReportService = serviceLocator.getReportService();
      FileOutputFormat outputFormat = new FileOutputFormat();
      outputFormat.setZipped(false);
      outputFormat.setFileOutputType(FileOutputType.CSV);
      long id = basicReportService.addReportRequest("<ACCOUNTID>", basicReportRequest, outputFormat);
      System.out.println("Requested report, id: " + id);

      for (int repeat = 0; repeat < 60; repeat++) {
      System.out.println("Waiting for report");
      Thread.sleep(3000);
      String downloadURL = basicReportService.getReportDownloadUrl(id).getDownloadUrl();
      if (downloadURL != null) {
      System.out.println("download url: " + downloadURL);
      break;
      }
      }
      }
      }

      labtrax
    • Show all 3 messages in this topic