spotonlive / php-google-my-business

Google MyBusiness
Apache License 2.0
29 stars 25 forks source link

Getting null when trying to access locations #16

Open lucasvm opened 4 years ago

lucasvm commented 4 years ago

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?