protected function generateAccess($query, $code = null, $refreshToken = false)
    {
        //if there is a code
        if (!is_null($code)) {
            //if you only want to refresh a token
            if ($refreshToken) {
                //put code in the query
                $query['refresh_token'] = $code;
            //else you want to request a token
            } else {
                //put code in the query
                $query[self::CODE] = $code;
            }
        }

        //set curl
        $curl = Curl::i()
          ->setUrl($this->accessUrl)
          ->verifyHost(false)
          ->verifyPeer(false)
          ->setHeaders(self::TYPE, self::REQUEST)
          ->setPostFields(http_build_query($query));

        $result =  $curl->getResponse();

        $this->meta     = $curl->getMeta();
        $this->meta['query'] = $query;
        $this->meta['url'] = $this->accessUrl;
        $this->meta['response']     = $result;

        //check if results is in JSON format
        if ($this->isJson($result)) {
            //if it is in json, lets json decode it
            $response =  json_decode($result, true);
        //else its not in json format
        } else {
            //parse it to make it an array
             parse_str($result, $response);
        }

        return $response;
    }
protected function generateAccess($query, $code = null, $refreshToken = false)
    {
        //if there is a code
        if (!is_null($code)) {
            //if you only want to refresh a token
            if ($refreshToken) {
                //put code in the query
                $query['refresh_token'] = $code;
            //else you want to request a token
            } else {
                //put code in the query
                $query[self::CODE] = $code;
            }
        }

        //set curl
        $curl = Curl::i()
          ->setUrl($this->accessUrl)
          ->verifyHost(false)
          ->verifyPeer(false)
          ->setHeaders(self::TYPE, self::REQUEST)
          ->setPostFields(http_build_query($query));

        $result =  $curl->getResponse();

        $this->meta     = $curl->getMeta();
        $this->meta['query'] = $query;
        $this->meta['url'] = $this->accessUrl;
        $this->meta['response']     = $result;

        //check if results is in JSON format
        if ($this->isJson($result)) {
            //if it is in json, lets json decode it
            $response =  json_decode($result, true);
        //else its not in json format
        } else {
            //parse it to make it an array
             parse_str($result, $response);
        }

        return $response;
    }
protected function generateAccess ( $ query , $ code = null , $ refreshToken = false ) { //if there is a code if ( ! is_null ( $ code ) ) { //if you only want to refresh a token if ( $ refreshToken ) { //put code in the query $ query [ 'refresh_token' ] = $ code ; //else you want to request a token } else { //put code in the query $ query [ self :: CODE ] = $ code ; } } //set curl $ curl = Curl :: i ( ) -> setUrl ( $ this -> accessUrl ) -> verifyHost ( false ) -> verifyPeer ( false ) -> setHeaders ( self :: TYPE , self :: REQUEST ) -> setPostFields ( http_build_query ( $ query ) ) ; $ result = $ curl -> getResponse ( ) ; $ this -> meta = $ curl -> getMeta ( ) ; $ this -> meta [ 'query' ] = $ query ; $ this -> meta [ 'url' ] = $ this -> accessUrl ; $ this -> meta [ 'response' ] = $ result ; //check if results is in JSON format if ( $ this -> isJson ( $ result ) ) { //if it is in json, lets json decode it $ response = json_decode ( $ result , true ) ; //else its not in json format } else { //parse it to make it an array parse_str ( $ result , $ response ) ; } return $ response ; }
Returns an access token from server

@param *string     $query        Query string to include in the URL
@param string|null $code         Usually from the URL after redirected back
@param *bool       $refreshToken Whether or not we need the tokens refreshed

@return string
Returns an access token from server