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

Change the headers content type with wp_remote_post

So, you set the headers of a request using wp_remote_post() and you expect that headers be used in the response. That is what I understand from you: When I print the response content-type is still “text/html” I think that you are missunderstanding the HTTP headers. Using wp_remote_post() you make a request and you can set … 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

Send data to 3rd party api with wp_remote_post on wp_login

The ‘body’ needs to be an array, not including the ‘json_encode($user)’ piece. $response = wp_remote_post( ‘myapp.com/endpoint’, array( ‘method’ => ‘POST’, ‘headers’ => array(‘Content-Type’ => ‘application/json; charset=utf-8’), ‘body’ => $user ) ); I have this in my function since I also had issues with the body being an object: if (is_object($user) && !is_array($user)) $user = json_decode(json_encode($user), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)