build a core reporting api query (php)

The analytics service object contains a method to build a Core Reporting API query. Each Core Reporting API query contains a set of parameters which specify what data to return. One of the most important query parameters is the ids parameter, or the table ID. This parameter specifies from which Google Analytics profile to retrieve data. The value is in the format ga:xxx where xxx is the profile ID.

function queryCoreReportingApi() {
  $optParams = array(
      \'dimensions\' => \'ga:source,ga:keyword\',
      \'sort\' => \'-ga:visits,ga:source\',
      \'filters\' => \'ga:medium==organic\',
      \'max-results\' => \'25\');

  return $service->data_ga->get(
      TABLE_ID,
      \'2010-01-01\',
      \'2010-01-15\',
      \'ga:visits\',
      $optParams);
}