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

Getting null when trying to access locations #16

Open
lucasvm opened this issue Mar 26, 2020 · 0 comments
Open

Getting null when trying to access locations #16

lucasvm opened this issue Mar 26, 2020 · 0 comments

Comments

@lucasvm
Copy link

lucasvm commented Mar 26, 2020

Hello All

Im using this gmb api client, and im trying to create new business locations on my account from the api.

I have done this:

 $accounts = $service->accounts->listAccounts()->getAccounts();
        $locations = $service->accounts_locations->listAccountsLocations($accounts[0]['name']); // get locations for the first account
        $request = new \Google_Service_MyBusiness_ReportLocationInsightsRequest;
        $request->setLocationNames($locations[0]['name']); // set first location to pull data for
        $actions = new \Google_Service_MyBusiness_BasicMetricsRequest;
        $actions->setMetricRequests(['metric' => 'ALL']);
        $time = new \Google_Service_MyBusiness_TimeRange;
        $time->setStartTime('2019-10-02T15:01:23.045123456Z');
        $time->setEndTime('2020-01-31T15:01:23.045123456Z');
        $actions->setTimeRange($time);
        $request->setBasicRequest($actions);
        $insights = $service->accounts_locations->reportInsights($accounts[0]['name'], $request);
        print_r($insights); // see object result structure / insights available

This is the error:
Error: Call to a member function listAccountsLocations() on null in

My account is approved i can see all the accounts when doing the list, but i cant access to the locations.

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant