src/MinecraftJP.php
public function requestClientCredentials($options = array()) {
        $options = array_merge(array(
            'scope' => '',
        ), $options);

        $res = $this->sendRequest('POST', $this->getUrl('oauth', 'token'), array(
            'client_id' => $this->getClientId(),
            'client_secret' => $this->getClientSecret(),
            'grant_type' => 'client_credentials',
            'scope' => $options['scope'],
        ));
        $result = $res->getBody();

        $token = null;
        if ($result && $result = json_decode($result, true)) {
            if (!empty($result['error'])) {
                throw new Exception($result['error_description']);
            }

            if (!empty($result['access_token'])) {
                $this->accessToken = $token = $result['access_token'];
            }
        }

        if (empty($token)) {
            throw new InvalidTokenException('token not available.');
        }

        return $token;
    }
public function requestClientCredentials($options = array()) {
        $options = array_merge(array(
            'scope' => '',
        ), $options);

        $res = $this->sendRequest('POST', $this->getUrl('oauth', 'token'), array(
            'client_id' => $this->getClientId(),
            'client_secret' => $this->getClientSecret(),
            'grant_type' => 'client_credentials',
            'scope' => $options['scope'],
        ));
        $result = $res->getBody();

        $token = null;
        if ($result && $result = json_decode($result, true)) {
            if (!empty($result['error'])) {
                throw new Exception($result['error_description']);
            }

            if (!empty($result['access_token'])) {
                $this->accessToken = $token = $result['access_token'];
            }
        }

        if (empty($token)) {
            throw new InvalidTokenException('token not available.');
        }

        return $token;
    }
public function requestClientCredentials ( $ options = array ( ) ) { $ options = array_merge ( array ( 'scope' => '' , ) , $ options ) ; $ res = $ this -> sendRequest ( 'POST' , $ this -> getUrl ( 'oauth' , 'token' ) , array ( 'client_id' => $ this -> getClientId ( ) , 'client_secret' => $ this -> getClientSecret ( ) , 'grant_type' => 'client_credentials' , 'scope' => $ options [ 'scope' ] , ) ) ; $ result = $ res -> getBody ( ) ; $ token = null ; if ( $ result && $ result = json_decode ( $ result , true ) ) { if ( ! empty ( $ result [ 'error' ] ) ) { throw new Exception ( $ result [ 'error_description' ] ) ; } if ( ! empty ( $ result [ 'access_token' ] ) ) { $ this -> accessToken = $ token = $ result [ 'access_token' ] ; } } if ( empty ( $ token ) ) { throw new InvalidTokenException ( 'token not available.' ) ; } return $ token ; }
Request Client Credentials token
Request Client Credentials token