cuongpd / gapi-google-analytics-php-interface

Automatically exported from code.google.com/p/gapi-google-analytics-php-interface
0 stars 0 forks source link

Optional dimensions #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call requestReportData with no dimensions parameter (set to null or '')

What is the expected output? What do you see instead?

According to the google data api Dimensions are optional so you should
still be able to send a request with this unset. However ga:pi sets
dimensions to the string 'ga:' which is invalid.

What version of the product are you using? On what operating system?

Version 1.3. OS X 10.5

Please provide any additional information below.

My solution would be to add a check for null or blank $dimensions parameter
and if null/blank do not add to parameter array.

Original issue reported on code.google.com by Harmonic...@gmail.com on 27 Aug 2009 at 5:29

GoogleCodeExporter commented 9 years ago
Here's my fix on line around 117 of the class file.  Works like a charm when no 
dimensions are set.  The only thing I changed was in the else statement, 
commenting out the old line and replacing it with "$parameters['dimensions'] = 
NULL;"

if(is_array($dimensions))
    {
      $dimensions_string = '';
      foreach($dimensions as $dimesion)
      {
        $dimensions_string .= ',ga:' . $dimesion;
      }
      $parameters['dimensions'] = substr($dimensions_string,1);
    }
    else 
    {
        $parameters['dimensions'] = NULL;
      #$parameters['dimensions'] = 'ga:'.$dimensions;
    }

Original comment by aaron.crawford@gmail.com on 29 Feb 2012 at 12:50

GoogleCodeExporter commented 9 years ago
oh, and in the request method/function if you don't have any dimensions just 
use NULL

Original comment by aaron.crawford@gmail.com on 29 Feb 2012 at 12:52