Skip to content

Getting null when trying to access locations #16

@lucasvm

Description

@lucasvm

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions