lib/RakutenRws/Client.php
public function fetchAccessTokenFromCode($code = null)
    {
        if ($code === null) {
            if (!isset($_GET['code'])) {
                throw new LogicException("A parameter code is not set.");
            }

            $code = $_GET['code'];
        }

        $url = $this->getAccessTokenUrl();
        $parameter = array(
            'grant_type'    => 'authorization_code',
            'client_id'     => $this->developerId,
            'client_secret' => $this->secret,
            'code'          => $code,
            'redirect_uri'  => $this->redirectUrl
        );

        $response = $this->httpClient->post(
            $url,
            $parameter
        );

        if ($response->getCode() == 200) {
            $this->accessTokenInfo = json_decode($response->getContents(), true);
            if (isset($this->accessTokenInfo['access_token'])) {
                $this->accessToken = $this->accessTokenInfo['access_token'];

                return $this->accessToken;
            }
        }

        return null;
    }
public function fetchAccessTokenFromCode($code = null)
    {
        if ($code === null) {
            if (!isset($_GET['code'])) {
                throw new LogicException("A parameter code is not set.");
            }

            $code = $_GET['code'];
        }

        $url = $this->getAccessTokenUrl();
        $parameter = array(
            'grant_type'    => 'authorization_code',
            'client_id'     => $this->developerId,
            'client_secret' => $this->secret,
            'code'          => $code,
            'redirect_uri'  => $this->redirectUrl
        );

        $response = $this->httpClient->post(
            $url,
            $parameter
        );

        if ($response->getCode() == 200) {
            $this->accessTokenInfo = json_decode($response->getContents(), true);
            if (isset($this->accessTokenInfo['access_token'])) {
                $this->accessToken = $this->accessTokenInfo['access_token'];

                return $this->accessToken;
            }
        }

        return null;
    }
public function fetchAccessTokenFromCode ( $ code = null ) { if ( $ code === null ) { if ( ! isset ( $ _GET [ 'code' ] ) ) { throw new LogicException ( "A parameter code is not set." ) ; } $ code = $ _GET [ 'code' ] ; } $ url = $ this -> getAccessTokenUrl ( ) ; $ parameter = array ( 'grant_type' => 'authorization_code' , 'client_id' => $ this -> developerId , 'client_secret' => $ this -> secret , 'code' => $ code , 'redirect_uri' => $ this -> redirectUrl ) ; $ response = $ this -> httpClient -> post ( $ url , $ parameter ) ; if ( $ response -> getCode ( ) == 200 ) { $ this -> accessTokenInfo = json_decode ( $ response -> getContents ( ) , true ) ; if ( isset ( $ this -> accessTokenInfo [ 'access_token' ] ) ) { $ this -> accessToken = $ this -> accessTokenInfo [ 'access_token' ] ; return $ this -> accessToken ; } } return null ; }
Fetches OAuth2 AccessToken from Code

@param string $code The Code
@return string The Access Token, If response is invalid return null
@throws LogicException
Fetches OAuth2 AccessToken from Code