schulzefelix / laravel-search-console

A Laravel package to retrieve data from Google Search Console
MIT License
47 stars 24 forks source link

Non static method 'setAccessToken()' could not be called statically #32

Closed RhysLees closed 2 years ago

RhysLees commented 2 years ago

When i use:

$sites = SearchConsole::setAccessToken($token)->listSites(); return $sites;

i get the following error: Non-static method SchulzeFelix\SearchConsole\SearchConsole::setAccessToken() cannot be called statically

RhysLees commented 2 years ago

I can not call it non-static either as its construct method requires "SearchConsoleClient $client"

schulzefelix commented 2 years ago

I guess you missing the

use SearchConsole;

statement in your class

RhysLees commented 2 years ago

I guess you missing the

use SearchConsole;

statement in your class

nope, its included, SearchConsole::setAccessToken() is not a stactic method

 /**
     * @param string|array $accessToken
     *
     * @return $this
     */
    public function setAccessToken($accessToken)
    {
      ....
    }

should be

 /**
     * @param string|array $accessToken
     *
     * @return $this
     */
    public static function setAccessToken($accessToken)
    {
      ....
    }
kingzamzon commented 2 years ago

@RhysLees any solution on this issue?? am currently stuck here

RhysLees commented 2 years ago

@kingzamzon the only thing I can suggest is to fork the repo and make the change above

kingzamzon commented 2 years ago

@RhysLees I made the changes but got more error on my end.. do you have a fork?

RhysLees commented 2 years ago

@RhysLees I made the changes but got more error on my end.. do you have a fork?

No sorry

kingzamzon commented 2 years ago

How were you able to sort yours out?

RhysLees commented 2 years ago

How were you able to sort yours out?

Just didn't use this package. I used a spatie package instead

schulzefelix commented 2 years ago

Hi, it definitely works with use SearchConsole; like the last 5 years.

NOT "use SchulzeFelix\SearchConsole\SearchConsole;"!

image

@RhysLees Which Spatie package you using for the SearchConsole?