Sending JSON Payload using Request::request_multiple()

You can’t. The requests library that comes bundled in WordPress doesn’t support this. The reason for this is that the request_multiple function only accepts these parameters: * @param array $requests Request data (array of ‘url’, ‘headers’, ‘data’, ‘options’) as per {@see Requests_Transport::request} body is not one of those parameters, which explains why your request is … Read more

Cache WP remote_get HTTP Response using Transients

function display_api_response() { $body = get_transient( ‘my_remote_response_value’ ); if ( false === $body ) { $api_url = “https://randletter2020.herokuapp.com”; $response = wp_remote_get($api_url); if (200 !== wp_remote_retrieve_response_code($response)) { return; } $body = wp_remote_retrieve_body($response); set_transient( ‘my_remote_response_value’, $body, 5*MINUTE_IN_SECONDS ); } if (‘a’ === $body) { echo ‘A wins’; } else { // Do something else. } } add_action(‘init’, … Read more

Behind-the-scenes HTTP Request?

Only use wp_remote_post() if you are actually posting something. Try using wp_remote_get() with a full url $url=”http://blabla.org/mailinglist/add?” . $user_email; $results = wp_remote_get( $url ); // var_dump( $results );

How to make Http Request to a php file present in plugin directory of wordpress

Here is a quick and dirty plugin that shows you how to achieve this (adapt this example to your own architecture and needs): <?php /* Plugin Name: Custom rewrite rule test */ add_action( ‘plugins_loaded’, array(Registration::get_instance(), ‘setup’) ); class Registration { protected static $instance = NULL; public function __construct() {} public static function get_instance() { NULL … Read more