src/Core/AbstractAPIBase.php
protected function request($method, array $args)
    {
        $http = $this->getHttp();
        // If didn`t set $args then set $args to the empty array
        $args = array_replace(['', [], []], $args);
        // Set the cookies
        if (!isset($args[2]['cookies'])) {
            $args[2]['cookies'] = $this->getCookie();
            // Set the query string xh
            $args[2]['query']['xh'] = $this->getUserName();
        }
        // Set the proxy and cross the campus network vpn
        if (Config::get('proxy_status', false)) {
            $args[2]['proxy'] = Config::get('proxy', '');
        }
        // Set the request headers
        if ($headers = Config::get('http_headers')) {
            $args[2]['headers'] = $headers;
        }
        // Get the viewstate field
        if (isset($args[1]['__VIEWSTATE']) && true === $args[1]['__VIEWSTATE']) {
            $args[1]['__VIEWSTATE'] = $this->getViewsState($args[0]);
        }
        // Set the uri prefix for the cookies in url
        $args[0] = Config::get('param.url_prefix', '') . $args[0];
        // Try to get the response
        $response = call_user_func_array([$http, $method], $args);
        // Check whether need to request again with the url prefix
        $body = (string)$response->getBody();
        // The case of "Object moved to <a href='/(palpi545qhgbee55fvfekz45)/path.aspx" retry to new uri
        if (preg_match('/Object\ moved\ to\ <a\ href=[\'"]?\/(\(\w+\))/i', $body, $matches)) {
            // Set the new retry request`s uri
            $uriPrefix = $matches[1] . '/';
            Config::set('param.url_prefix', $uriPrefix);
            // Reset the request url path and request again
            $args[0] = $uriPrefix . $args[0];
            $response = call_user_func_array([$http, $method], $args);
        }

        return $response;
    }
protected function request($method, array $args)
    {
        $http = $this->getHttp();
        // If didn`t set $args then set $args to the empty array
        $args = array_replace(['', [], []], $args);
        // Set the cookies
        if (!isset($args[2]['cookies'])) {
            $args[2]['cookies'] = $this->getCookie();
            // Set the query string xh
            $args[2]['query']['xh'] = $this->getUserName();
        }
        // Set the proxy and cross the campus network vpn
        if (Config::get('proxy_status', false)) {
            $args[2]['proxy'] = Config::get('proxy', '');
        }
        // Set the request headers
        if ($headers = Config::get('http_headers')) {
            $args[2]['headers'] = $headers;
        }
        // Get the viewstate field
        if (isset($args[1]['__VIEWSTATE']) && true === $args[1]['__VIEWSTATE']) {
            $args[1]['__VIEWSTATE'] = $this->getViewsState($args[0]);
        }
        // Set the uri prefix for the cookies in url
        $args[0] = Config::get('param.url_prefix', '') . $args[0];
        // Try to get the response
        $response = call_user_func_array([$http, $method], $args);
        // Check whether need to request again with the url prefix
        $body = (string)$response->getBody();
        // The case of "Object moved to <a href='/(palpi545qhgbee55fvfekz45)/path.aspx" retry to new uri
        if (preg_match('/Object\ moved\ to\ <a\ href=[\'"]?\/(\(\w+\))/i', $body, $matches)) {
            // Set the new retry request`s uri
            $uriPrefix = $matches[1] . '/';
            Config::set('param.url_prefix', $uriPrefix);
            // Reset the request url path and request again
            $args[0] = $uriPrefix . $args[0];
            $response = call_user_func_array([$http, $method], $args);
        }

        return $response;
    }
protected function request ( $ method , array $ args ) { $ http = $ this -> getHttp ( ) ; // If didn`t set $args then set $args to the empty array $ args = array_replace ( [ '' , [ ] , [ ] ] , $ args ) ; // Set the cookies if ( ! isset ( $ args [ 2 ] [ 'cookies' ] ) ) { $ args [ 2 ] [ 'cookies' ] = $ this -> getCookie ( ) ; // Set the query string xh $ args [ 2 ] [ 'query' ] [ 'xh' ] = $ this -> getUserName ( ) ; } // Set the proxy and cross the campus network vpn if ( Config :: get ( 'proxy_status' , false ) ) { $ args [ 2 ] [ 'proxy' ] = Config :: get ( 'proxy' , '' ) ; } // Set the request headers if ( $ headers = Config :: get ( 'http_headers' ) ) { $ args [ 2 ] [ 'headers' ] = $ headers ; } // Get the viewstate field if ( isset ( $ args [ 1 ] [ '__VIEWSTATE' ] ) && true === $ args [ 1 ] [ '__VIEWSTATE' ] ) { $ args [ 1 ] [ '__VIEWSTATE' ] = $ this -> getViewsState ( $ args [ 0 ] ) ; } // Set the uri prefix for the cookies in url $ args [ 0 ] = Config :: get ( 'param.url_prefix' , '' ) . $ args [ 0 ] ; // Try to get the response $ response = call_user_func_array ( [ $ http , $ method ] , $ args ) ; // Check whether need to request again with the url prefix $ body = ( string ) $ response -> getBody ( ) ; // The case of "Object moved to <a href='/(palpi545qhgbee55fvfekz45)/path.aspx" retry to new uri if ( preg_match ( '/Object\ moved\ to\ <a\ href=[\'"]?\/(\(\w+\))/i' , $ body , $ matches ) ) { // Set the new retry request`s uri $ uriPrefix = $ matches [ 1 ] . '/' ; Config :: set ( 'param.url_prefix' , $ uriPrefix ) ; // Reset the request url path and request again $ args [ 0 ] = $ uriPrefix . $ args [ 0 ] ; $ response = call_user_func_array ( [ $ http , $ method ] , $ args ) ; } return $ response ; }
Send a request with some options

@param string $method
@param array  $args

@return ResponseInterface
Send a request with some options