Last active
February 18, 2019 19:42
-
-
Save kamaroly/e5281641a1b2e76958ddc883f32996d8 to your computer and use it in GitHub Desktop.
Call external API using WordPress / WooCommerce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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