Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'Kurt\Google\Analytics\Exceptions\InvalidPeriodException' not found #8

Closed
baddwin opened this issue Jan 27, 2017 · 13 comments
Closed
Assignees

Comments

@baddwin
Copy link

baddwin commented Jan 27, 2017

in Period.php line 95
at Period->validatePeriod(object(Carbon), object(Carbon)) in Period.php line 77
at Period->setEndDate(object(Carbon)) in DatesHandler.php line 51
at Analytics->setEndDate(object(Carbon)) in AdminController.php line 43
at AdminController->__construct(object(Analytics))
at ReflectionClass->newInstanceArgs(array(object(Analytics))) in Container.php line 794
at Container->build('App\Http\Controllers\AdminController', array()) in Container.php line 644
at Container->make('App\Http\Controllers\AdminController', array()) in Application.php line 709
at Application->make('App\Http\Controllers\AdminController') in Route.php line 203
......

Hi, I tried to set startDate and endDate in cunstructor manually, but always ended up getting error above. But after I changed the code of Period.php at line 51 to this: $this->validatePeriod(null, $startDate); the error has gone. so what's going on there?

Edit: o yeah, I also got the result of API call like this.

screenshot_20170127_095707

Why the month numbers of December become 11 instead of 12 and for January also 00 instead of 01?

@OzanKurt
Copy link
Owner

1- Can you please provide which dates you entered to the constructor?

2- Sadly, the google analytics API returns the months starting from 0. It's confusing but it's how it is. ✌️

@baddwin
Copy link
Author

baddwin commented Jan 28, 2017

private $ga;

    function __construct(GoogleAnalytics $ga) {
        $this->middleware('auth');
        $this->ga = $ga;
        $ga->setStartDate(Carbon::parse('7 days ago'));
        $ga->setEndDate(Carbon::parse('yesterday'));
    }

is it what you meant?

@OzanKurt
Copy link
Owner

OzanKurt commented Jan 28, 2017 via email

@baddwin
Copy link
Author

baddwin commented Jan 29, 2017

o yeah, I forgot to mention that I'm in Laravel 5.3

@OzanKurt
Copy link
Owner

Are you sure that the carbon objects are giving you the expected results?

@baddwin
Copy link
Author

baddwin commented Jan 30, 2017

I'm rather confused though, but that's what I get

@baddwin
Copy link
Author

baddwin commented Feb 7, 2017

So, what should I do?
And how should I parse google API return data of Date(2017, 00, 01) in PHP, for instance?

@OzanKurt
Copy link
Owner

OzanKurt commented Feb 7, 2017

You can simply do +1.

@baddwin
Copy link
Author

baddwin commented Feb 7, 2017

OK, thank you

@baddwin
Copy link
Author

baddwin commented Feb 8, 2017

Wait, I didn't notice the last hotfix. As soon as I found it yesterday, I updated the package to it, but my issue still persist before I change line 51 of Period.php

@OzanKurt
Copy link
Owner

OzanKurt commented Feb 8, 2017

You should be getting an Exception as expected. Can you show me the error message?

@baddwin
Copy link
Author

baddwin commented Feb 11, 2017

Okay, I got it that date response value like Date(2017, 00, 01) is likely intended to be parsed for Javascript's Date method.

As for the error message I got, it's likely triggered by setStartDate and setEndDate method of $ga instance. So, please just tell me or give me an example how to set start and end date of the analytics data that I want.

@baddwin
Copy link
Author

baddwin commented May 22, 2017

Please help I still don't get it to set start date and end date.
I just want to get analytics for past week.

Edit: solved.

@baddwin baddwin closed this as completed May 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants