Skip to content

Instantly share code, notes, and snippets.

@kamaroly
Last active February 18, 2019 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamaroly/e5281641a1b2e76958ddc883f32996d8 to your computer and use it in GitHub Desktop.
Save kamaroly/e5281641a1b2e76958ddc883f32996d8 to your computer and use it in GitHub Desktop.
Call external API using WordPress / WooCommerce
/**
* Call external API
* @param string $endPoint
* @param array $data
* @param array $headers
* @return OBJECT
*/
function callApi($data,$headers,$endPoint='wp-json/wc/v2/orders',$method='POST'){
return wp_remote_post( home_url($endPoint), array(
'method' => $method,
'body' => json_encode($data),
'timeout' => 300,
'sslverify' => false,
'headers' => $headers
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment