lib/TheTwelve/Foursquare/AuthenticationGateway.php
public function authenticateUser($code)
    {

        if (!$this->canAuthenticateUser()) {
            throw new \RuntimeException(
            	'Cannot authenticate user, dependencies are missing'
            );
        }

        if (!$this->codeIsValid($code)) {
            throw new \InvalidArgumentException('Foursquare code is invalid');
        }

        $response = json_decode($this->httpClient->get($this->accessTokenUri, array(
            'client_id' => $this->clientId,
            'client_secret' => $this->clientSecret,
            'grant_type' => 'authorization_code',
            'redirect_uri' => $this->redirectUri,
            'code' => $code,
        )));

        $this->token = isset($response->access_token)
            ? $response->access_token : null;

        return $this->token;

    }
public function authenticateUser($code)
    {

        if (!$this->canAuthenticateUser()) {
            throw new \RuntimeException(
            	'Cannot authenticate user, dependencies are missing'
            );
        }

        if (!$this->codeIsValid($code)) {
            throw new \InvalidArgumentException('Foursquare code is invalid');
        }

        $response = json_decode($this->httpClient->get($this->accessTokenUri, array(
            'client_id' => $this->clientId,
            'client_secret' => $this->clientSecret,
            'grant_type' => 'authorization_code',
            'redirect_uri' => $this->redirectUri,
            'code' => $code,
        )));

        $this->token = isset($response->access_token)
            ? $response->access_token : null;

        return $this->token;

    }
public function authenticateUser ( $ code ) { if ( ! $ this -> canAuthenticateUser ( ) ) { throw new \ RuntimeException ( 'Cannot authenticate user, dependencies are missing' ) ; } if ( ! $ this -> codeIsValid ( $ code ) ) { throw new \ InvalidArgumentException ( 'Foursquare code is invalid' ) ; } $ response = json_decode ( $ this -> httpClient -> get ( $ this -> accessTokenUri , array ( 'client_id' => $ this -> clientId , 'client_secret' => $ this -> clientSecret , 'grant_type' => 'authorization_code' , 'redirect_uri' => $ this -> redirectUri , 'code' => $ code , ) ) ) ; $ this -> token = isset ( $ response -> access_token ) ? $ response -> access_token : null ; return $ this -> token ; }
authenticate the user with the response code
@see https://developer.foursquare.com/overview/auth.html
@param string $code
@throws \RuntimeException
@throws \InvalidArgumentException
@return string
authenticate the user with the response code