WP_HTTP_Requests_Response example

$options['proxy']->pass               = $proxy->password();
            }
        }

        // Avoid issues where mbstring.func_overload is enabled.         mbstring_binary_safe_encoding();

        try {
            $requests_response = WpOrg\Requests\Requests::request( $url$headers$data$type$options );

            // Convert the response into an array.             $http_response = new WP_HTTP_Requests_Response( $requests_response$parsed_args['filename'] );
            $response      = $http_response->to_array();

            // Add the original object to the array.             $response['http_response'] = $http_response;
        } catch ( WpOrg\Requests\Exception $e ) {
            $response = new WP_Error( 'http_request_failed', $e->getMessage() );
        }

        reset_mbstring_encoding();

        /** * Fires after an HTTP API response is received and before the response is returned. * * @since 2.8.0 * * @param array|WP_Error $response HTTP response or WP_Error object. * @param string $context Context under which the hook is fired. * @param string $class HTTP transport used. * @param array $parsed_args HTTP request arguments. * @param string $url The request URL. */
Home | Imprint | This part of the site doesn't use cookies.