I am working with the Woocommerce REST API and need to add a product to the store.
It worked before. Now I have this error:
stdClass Object ( [errors] => Array (
[0] => stdClass Object ( [code] =>
woocommerce_api_invalid_remote_product_image
[message] => Error getting remote image
https://www.google.lt/images/srpr/logo11w.png ) ) )
Here is the documentation for adding a product via the WooCommerce REST API http://woothemes.github.io/woocommerce-rest-api-docs/#create-a-product
Here is my code:
$dataArray = array(
'title' => 'xxxxxxxxxx',
'description' => 'description1',
'price' => '69',
'sku' => 'sku2',
'tags' => 'tag1, tag2, tag3',
'color' => array('red', 'blue'),
'size' => array('S', 'M'),
'image' => 'https://www.google.lt/images/srpr/logo11w.png'
);
public function addProduct($data)
{
$wc_api = $this->_getClient();
$newProductData = array(
'product' => array(
'title' => $data['title'],
'type' => 'variable',
'regular_price' => $data['price'],
'description' => $data['description'],
'sku' => $data['sku'],
'tags' => [ $data['tags'] ],
'images' => [ array('src' => $data['image'], 'position' => '0') ],
'virtual' => true
)
);
return $wc_api->create_product($newProductData);
}
I'm using this client to call the REST API
https://github.com/kloon/WooCommerce-REST-API-Client-Library
EDITED: If I get image from wordpress where woocommerce is hosted then all is fine. But, if I use a link from another site then I get an error.