Posting an XML request using HTTP API

I figured it out. The WordPress HTTP API was doing it’s job; my problem was with the API I was working with. I just modified my code like: $url=”https://www.testurl.com”; $xml = <<<TESTED XML HERE>>>; $response = wp_remote_post( $url, array( ‘method’ => ‘POST’, ‘timeout’ => 45, ‘redirection’ => 5, ‘httpversion’ => ‘1.0’, ‘headers’ => array( ‘Content-Type’ … Read more

cURL vs WP_Http for safety?

The WP_Http class is essentially a wrapper for cURL in the same way that wpdb is essentially a wrapper for mysqli. As such, implemented properly, using cURL directly is exactly as safe as using WP_Http (since WP_Http uses cURL to make the requests). That said, implementing cURL functions optimally isn’t the easiest thing in the … Read more

Difference between wp_remote_post and wp_safe_remote_post

[*][**] So is there ever any other situation in which I would want to use wp_remote_post or should I always stick with wp_safe_remote_post? The two functions are exactly the same, except wp_safe_remote_post() sets the reject_unsafe_urls argument to true. That argument causes the URL to be passed through wp_http_validate_url() in WP_Http::request(). From that function, we see … Read more

Error timed out with succesfull wp_remote_post

After quite some time letting the error message bugging my screen, I figured out a way to solve this. Yes, it’s a timeout issue, and the codex didn’t help me much. So I tried another approach, by setting a filter; add_filter( ‘http_request_timeout’, ‘wp9838c_timeout_extend’ ); function wp9838c_timeout_extend( $time ) { // Default timeout is 5 return … Read more

Mutual Authentiction on HTTPS with WordPress HTTP API?

Re the WP HTTP API look for the sslverify and sslcertificates args in this docs page: https://developer.wordpress.org/reference/classes/wp_http/request/. sslverify defaults to true and sslcertificates accepts an absolute path to a certificate file. If you’re going to be doing a lot of lifting with this API (sounds like it for a real estate site), I would suggest … Read more

How do I mock HTTP requests for PHPUnit?

If you take a look at WP_HTTP->request() (which all related functions wrap) it provides a filter hook for the purpose of overriding making a request in favor of returning arbitrary data as response: // Allow plugins to short-circuit the request $pre = apply_filters( ‘pre_http_request’, false, $r, $url ); if ( false !== $pre ) return … Read more

How to control accept encoding on HTTP API requests?

Quite an edge case, but the accepted encoding types should be filterable nonetheless. I can see a few situations where fine, granular control over this header would be useful (as in adding an API that uses non-standard encoding). So, while there’s no stock hook for this, I have created a Trac ticket for it and … Read more

techhipbettruvabetnorabahisbahis forumutaraftarium24eduedusedueduseduedueduseduedusedu