WordPress cURL and wp_remote_post
I solved it. For some reason it is working now, after adding httpversion and the sslverify. Hope this helps someone:
$result = wp_remote_post($url, array( 'method' => 'POST', 'headers' => $headers, 'httpversion' => '1.0', 'sslverify' => false, 'body' => json_encode($fields)) );
The previous answer did not work for me.Maybe because its from 2015.
Im am using wp_remote_post()
from my WordPress plugin.No curl()
calls.
The following did work, note the few additions: timeout, redirection and blocking.WP 5+
$result = wp_remote_post($url, array( 'method' => 'POST', 'headers' => $headers, 'timeout' => 60, // added 'redirection' => 5, // added 'blocking' => true, // added 'httpversion' => '1.0', 'sslverify' => false, 'body' => json_encode($fields)));