WordPress getting data from external API

If the API requires an authorization as Bearer token, just write is as Bearer and not as Basic: $headers = array( ‘Content-Type’ => ‘application/x-www-form-urlencoded’, ‘Authorization’ => ‘Beaerer Base64enodedusercredentials’, ); Also take a look at the documentation of this API. Also, make sure that you are currently duplicating the feedback in both of your functions. The … 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

Create plugin/function to catch XML-data via Shortcode

If this file is remotely available to you, then you should be using the HTTP API. $response = wp_remote_request( ‘http://xml.prisguide.no/productExport.php?productId=151690’ ,array( ‘ssl_verify’ => true // If the request isn’t working, try it with `false` ) ); You then simply go and catch the response and check if it’s an error: if ( is_wp_error( $response ) … Read more

Using the wp_remote_post response body

Your question doesn’t make a lot of sense. The submission works but I get the returned URL as an HTML stream in $response[‘body’] but I cannot seem to get any query string values from it. That is what is supposed to happen. You requesting a web page just as when you click a link in … Read more

How to use wp_http with https-pages?

You will probably need to look at the sslverify argument and modify the plugin to use this. See the documentation http://codex.wordpress.org/HTTP_API The ‘sslverify’ argument was added in Version 2.8 and will check to see if the SSL certificate is valid (not self-signed, actually for the site in the request) and will deny the response if … Read more

tech