wp_remote_post and form post

wp_remote_get returns a json string. You have different function to work with this json response. wp_remote_head() wp_remote_retrieve_body(), wp_remote_retrieve_header(), wp_remote_retrieve_headers(), wp_remote_retrieve_response_code(), wp_remote_retrieve_response_message() The example from the codex: $response = wp_remote_get( ‘http://www.example.com/index.html’ ); if( is_array($response) ) { $header = $response[‘headers’]; // array of http header lines $body = $response[‘body’]; // use the content } Depending on the … Read more

wp_remote_post rabobank omnikassa (version2) – error 5001

turns out (in case it’s helpful to someone else) that $omnikassaOrder[‘signature’] = hash_hmac(‘sha512’, json_encode(implode(‘,’,$toHash)), base64_decode($SigningKey)); should have been simply the following (without json_encode ) $omnikassaOrder[‘signature’] = hash_hmac(‘sha512’, implode(‘,’,$toHash), base64_decode($SigningKey));

wp_remote_post code conversion

Use this code : $url=”https://xxxx.yyyyy.zzzzz”; $body_array = array( ‘object_type’ => ‘Leaderboard’, ‘action’ => ‘list’, ‘pagination’ => array( ‘limit’ => 5, ‘order’ => false ), ‘data’ => array( ‘username’ => ‘[email protected]’ ) ); $response = wp_remote_post( $url, array( ‘method’ => ‘POST’, ‘timeout’ => 45, ‘redirection’ => 5, ‘httpversion’ => ‘1.0’, ‘blocking’ => true, ‘headers’ => array( … Read more

Inconsistencies between wp_remote_post and cURL

As discovered above, headers need to be (seems so obvious now) key-value pairs, as opposed to an array of json-style key-values: $headers = array(); $headers[‘Content-Type’] = ‘application/json’; $headers[‘Api-Key’] = ‘{myapikey}’; $headers[‘Siteid’] = ‘99999’; And the body needs to be json so either: ‘body’ => “{\n \”Username\”: \”Siteowner\”,\n \”Password\”: \”apitest1234\”\n}” or ‘body’ => json_encode(array( ‘Username’ => … Read more