Convert HTTP_Request2 to wp_remote_post

The issue might be with how you’re passing the XML data in the request body. In the wp_remote_post function try this” $xmlCustomerDataByAuthorLicenseID = ‘<GetCustomerDataByAuthor><AuthorID>ABC123</AuthorID></GetCustomerDataByAuthor>’; $response = wp_remote_post( $urlCustomerDataByAuthor, array( ‘method’ => ‘POST’, ‘headers’ => array( ‘Content-Type’ => ‘text/xml’ ), ‘body’ => $xmlCustomerDataByAuthorLicenseID, ‘sslverify’ => false ) ); if (wp_remote_success($response)) { $xmlDataParsed = simplexml_load_string($response[‘body’]); foreach ($xmlDataParsed->{“Customer”} … Read more

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

upload image with rest API to the media library

Does functions.php continuously execute while WordPress is running? Yes, it’s run on each page load. You can learn more about the (theme) functions file at https://developer.wordpress.org/themes/basics/theme-functions/. Should this be in functions.php file and how do i get it to execute only once? It can be put in that file, however, it should be run conditionally, … Read more

wp_remote_post() and Pem certificates

No, there are no provisions in wp_remote_post for those parameters. wp_remote_post is a high level abstraction around a deeper level API which itself is another wrapper around the Requests library ( which itself provides an abstraction that handles support for multiple HTTP backends, not all servers have curl, or the same versions of curl ). … Read more