public function authenticate($code = null)
    {
        if (null === $code) {
            if (isset($_GET['code'])) {
                $code = $_GET['code'];
            }
        }

        $url = 'https://oauth.vk.com/access_token?' . http_build_query(array(
                'client_id' => $this->getClientId(),
                'client_secret' => $this->getClientSecret(),
                'code' => $code,
                'redirect_uri' => $this->getRedirectUri(),
            ));

        $token = $this->curl($url);
        $decodedToken = json_decode($token, true);
        $decodedToken['created'] = time(); // add access token created unix timestamp to array

        $this->setAccessToken($decodedToken);

        return $this;
    }
public function authenticate($code = null)
    {
        if (null === $code) {
            if (isset($_GET['code'])) {
                $code = $_GET['code'];
            }
        }

        $url = 'https://oauth.vk.com/access_token?' . http_build_query(array(
                'client_id' => $this->getClientId(),
                'client_secret' => $this->getClientSecret(),
                'code' => $code,
                'redirect_uri' => $this->getRedirectUri(),
            ));

        $token = $this->curl($url);
        $decodedToken = json_decode($token, true);
        $decodedToken['created'] = time(); // add access token created unix timestamp to array

        $this->setAccessToken($decodedToken);

        return $this;
    }
public function authenticate ( $ code = null ) { if ( null === $ code ) { if ( isset ( $ _GET [ 'code' ] ) ) { $ code = $ _GET [ 'code' ] ; } } $ url = 'https://oauth.vk.com/access_token?' . http_build_query ( array ( 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getClientSecret ( ) , 'code' => $ code , 'redirect_uri' => $ this -> getRedirectUri ( ) , ) ) ; $ token = $ this -> curl ( $ url ) ; $ decodedToken = json_decode ( $ token , true ) ; $ decodedToken [ 'created' ] = time ( ) ; // add access token created unix timestamp to array $ this -> setAccessToken ( $ decodedToken ) ; return $ this ; }
Authenticate user and get access token from server

@param string $code

@return $this
Authenticate user and get access token from server