How to run wp_remote_get() for SPA page?

The problem with SPAs is a lot of the content is rendered by Javascript, so it will only have the full DOM if it’s requested by something that executes Javascript. wp_remote_get() is not the tool for that job, you’d have to script visiting the page with a headless browser.

wp_http remote request not respecting timeout

I suspect this is the cause in the Requests library that powers WP_HTTP: Transfer & connect timeouts, in seconds & milliseconds cURL is unable to handle timeouts under a second in DNS lookups, so we round those up to ensure 1-999ms isn’t counted as an instant failure. The code looks to be here: https://github.com/WordPress/Requests/blob/90db63ab54449c071fc2192a4fc3487cafbf67d0/src/Transport/Curl.php#L448-L460 if … Read more

Problem getting wp posts in plugin with wp_remote_get

I did some changes on my code $remoteargs = array( ‘timeout’ => 20, ‘redirection’ => 5, ‘httpversion’ => ‘1.1’, ‘blocking’ => false, ‘headers’ => array(), ‘cookies’ => array(), ‘body’ => array(), ‘sslverify’ => false, ); $response = wp_remote_get( ‘http://localhost/wordpress/wp-json/wp/v2/posts’,$remoteargs); // Exit if error. if ( is_wp_error( $response ) ) { echo $response->get_error_message(); return; } // … Read more

wp_remote_get with Google Books API

I’m pretty sure you have to add the keywords or the search terms directly to the query, for example: $key = ‘flowers’; // search for word flowers in book titles. // fill rest in as you desire $args = array( ‘timeout’ => ‘5’, ‘redirection’ => ‘5’, ‘sslverify’ => false // for localhost ); //check for … Read more

tech