NicklasWallgren / PokemonGoAPI-PHP

Pokemon Go API PHP library
BSD 2-Clause "Simplified" License
130 stars 51 forks source link

Error #143

Closed RazzaFrazza closed 7 years ago

RazzaFrazza commented 7 years ago

Does anyone know why I'm getting the below error when I go to my view? I'm using Laravel 5

FatalErrorException in ClientProxy.php line 15:
Declaration of ClientProxy::request($method, $uri, array $options = Array) must be compatible with GuzzleHttp\ClientInterface::request($method, $uri = NULL, array $options = Array)
class pokemonController extends Controller
{

    public function run(Request $request)
    {
        // EXAMPLE Authentication via Google user credentials
        $config = new Config();
        $config->setProvider(Factory::PROVIDER_GOOGLE);
        $config->setUser(Auth::User()->pokego_username);
        $config->setPassword(Auth::User()->pokego_password);
        // Create the authentication manager
        $manager = Factory::create($config);
        // Add a event listener,
        $manager->addListener(function ($event, $value) {
            if ($event === Manager::EVENT_ACCESS_TOKEN) {
                /** @var AccessToken $accessToken */
                $accessToken = $value;
                // Persist the access token in session storage, cache or whatever.
                // The persisted access token should be passed to the Authentication factory for authentication
            }
        });
        // Initialize the pokemon go application
        $application = new ApplicationKernel($manager);

        // Retrieve the pokemon go api instance
        $pokemonGoApi = $application->getPokemonGoApi();
        // Retrieve the profile
        $profile = $pokemonGoApi->getProfile();
        // Retrieve the profile data
        $profileData = $profile->getData();
        echo sprintf('The profile data: %s', print_r($profileData, true));
    }

}
DrDelay commented 7 years ago

You get this error because you are using a version of Guzzle before https://github.com/guzzle/guzzle/commit/acd0bcded6705fa53d3150661a5709cea5b08000 (tagged as 6.2.1). A composer update should fix that temporarily.

But it is not your fault, the composer.json of this project should require ^6.2.1 to avoid this problem.

Edit: Not so nice that a popular package like Guzzle does not comply to Semantic Versioning.