protected JSONObject requestServer ( AipRequest request ) { // 请求API AipResponse response = AipHttpClient . post ( request ) ; String resData = response . getBodyStr ( ) ; Integer status = response . getStatus ( ) ; if ( status . equals ( 200 ) && ! resData . equals ( "" ) ) { try { JSONObject res = new JSONObject ( resData ) ; if ( state . getState ( ) . equals ( EAuthState . STATE_POSSIBLE_CLOUD_USER ) ) { boolean cloudAuthState = res . isNull ( "error_code" ) || res . getInt ( "error_code" ) != AipClientConst . IAM_ERROR_CODE ; state . transfer ( cloudAuthState ) ; if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "state after cloud auth: " + state . toString ( ) ) ; } if ( ! cloudAuthState ) { return Util . getGeneralError ( AipClientConst . OPENAPI_NO_ACCESS_ERROR_CODE , AipClientConst . OPENAPI_NO_ACCESS_ERROR_MSG ) ; } } return res ; } catch ( JSONException e ) { return Util . getGeneralError ( - 1 , resData ) ; } } else { LOGGER . warn ( String . format ( "call failed! response status: %d, data: %s" , status , resData ) ) ; return AipError . NET_TIMEOUT_ERROR . toJsonResult ( ) ; } }
send request to server