Am trying to add products using a rest API provided by woo commerce but it gives me the below error.
Fatal error: Uncaught exception 'Exception' with message 'WooCommerce REST API client requires the cURL PHP extension.' in C:\Apache24\htdocs\WooCommerce-REST-API-Client-Library-master\lib\woocommerce-api\class-wc-api-client.php:86 Stack trace: #0 C:\Apache24\htdocs\WooCommerce-REST-API-Client-Library-master\example\example.php(11): WC_API_Client->__construct('http://www.woot...', 'ck_xxxxxxx...', 'cs_xxxxxxx...', Array) #1 {main} thrown in C:\Apache24\htdocs\WooCommerce-REST-API-Client-Library-master\lib\woocommerce-api\class-wc-api-client.php on line 86
require_once( 'C:/Apache24/htdocs/WooCommerce-REST-API-Client-Library-master/lib/woocommerce-api.php' );
$options = array(
'ssl_verify' => false,
);
try {
$client = new WC_API_Client( 'http://www.example.com/demo/wpinsttalledlocation', 'ck_xxxxxxxxxxxxxxxxxxxxxx', 'cs_xxxxxxxxxxxxxxxxxxxxxxxxxx', $options );
} catch ( WC_API_Client_Exception $e ) {
echo $e->getMessage() . PHP_EOL;
echo $e->getCode() . PHP_EOL;
if ( $e instanceof WC_API_Client_HTTP_Exception ) {
print_r( $e->get_request() );
print_r( $e->get_response() );
}
}
You need install php-curl.
sudo apt-get install php5.6-curl (or your version php)
and then, restart apache.
sudo service apache2 restart