How to set charset for wp_remote_post request?

After trying several times to set the proper charset, I wasn’t successful. Then I searched for an workaround and found one that worked with my problem. In addition to set the charset like I mentioned above, what I did is to convert all strings on my POST body with this php snippet: $message = @iconv(“UTF-8″,”Windows-1252//IGNORE”,$message); … Read more

Stuck with wp_remote_post sending data to an external api on user registration

I recommend only setting the arguments you absolutely need to change from defaults, to eliminate potential issues while testing. It’s best to only add additional arguments as they are needed. All arguments can be found here: https://developer.wordpress.org/reference/classes/WP_Http/request/ If possible also remove the required authentication at first to just test the POST before adding in security/authentication. … Read more

wp_remote_post doesn’t work with more than 1024 bytes in the body

If you happen to be using the CURL transport, then it sometimes has minor problems sending POST requests greater than 1024 characters. More info here: https://stackoverflow.com/questions/463144/php-http-post-fails-when-curl-data-1024 The fix suggested there is to send an empty Expect: header. You can do this by modifying your code thusly: $response = wp_remote_post( $url, array( ‘timeout’ => 60, ‘redirection’ … 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

Wp_remote_post not posting data

You’re passing request params incorrectly. Take a look at Codex page. You can find such example in there: $response = wp_remote_post( $url, array( ‘method’ => ‘POST’, ‘timeout’ => 45, ‘redirection’ => 5, ‘httpversion’ => ‘1.0’, ‘blocking’ => true, ‘headers’ => array(), ‘body’ => array( ‘username’ => ‘bob’, ‘password’ => ‘1234xyz’ ), ‘cookies’ => array() ) … Read more