0

I'm starting a Laravel site and decided to include the Google Analytics package here https://github.com/thujohn/analytics-l4

After configuring it properly with my credentials and placing the .p12 file, I tried this:

<?php $site_id = Analytics::getSiteIdByUrl('http://example.com');
      $stats = Analytics::query($site_id, '7daysAgo', 'yesterday', 'ga:visits,ga:pageviews');
        echo $stats;
      ?>

It's close, but then it hits an open_basedir error. Here is the error code:

ErrorException (E_UNKNOWN) file_exists(): open_basedir restriction in effect. File(/tmp/Google_Client/e4/e4376171b3c41df2c55e1a689f6386c9) is not within the allowed path(s): (/var/zpanel/hostdata/zadmin/public_html/:/var/zpanel/temp/)

You can see that path is way wrong. Not sure where to correct that. Not sure what else to do. Any help is appreciated. Thanks

hdwebpros
  • 528
  • 3
  • 7
  • 20

1 Answers1

1

Where is located your .p12 file ?

It should be placed in /app/config/packages/thujohn/analytics

thujohn
  • 55
  • 8
  • It is placed exactly there – hdwebpros Feb 17 '15 at 19:21
  • And in config.php you have : 'certificate_path' => \_\_DIR__ . '/xxxxxxxxxxxxxxxxx-privatekey.p12', – thujohn Feb 17 '15 at 19:25
  • Yes, I do, but I replaced the x's with the appropriate .p12 file name – hdwebpros Feb 17 '15 at 19:28
  • Is it a local server ? If your .p12 file wasn't find you should have this error : https://github.com/thujohn/analytics-l4/blob/master/src/Thujohn/Analytics/AnalyticsServiceProvider.php#L32 – thujohn Feb 17 '15 at 20:21
  • It finds the .p12 file just fine. That's not the issue. The issue is that it is trying to put the cache file in a place that doesn't exist. See the path in the error: "path(s): (/var/zpanel/hostdata/zadmin/public_html/:/var/zpanel/temp/)". You can see that path won't work for obvious reasons. Just not sure why it is trying to place the temp cache file there. – hdwebpros Feb 17 '15 at 20:25
  • My mistake I was thinking of something else... Is the exception returned by $stats ? What returns dd($stats) ? – thujohn Feb 17 '15 at 20:31
  • It doesn't get to that point, so I can't DD it. The exception occurs when I use Analytics::getSiteIdByUrl or anything Analytics:: I'm sure. – hdwebpros Feb 17 '15 at 20:41
  • For reference, vendor/google/apiclient/src/Google/Cache/File.php throws the error on "if (!file_exists($storageFile))". Although, the issue is more of why it is trying to store the file in that silly location – hdwebpros Feb 17 '15 at 20:46
  • I just tried and I don't have any problem. I think you should try to explain your problem in their repo : https://github.com/google/google-api-php-client – thujohn Feb 17 '15 at 21:31
  • Okay, I submitted an issue here: https://github.com/google/google-api-php-client/issues/487. Let's hope this gets figured out. Thanks for looking into it. – hdwebpros Feb 18 '15 at 17:59