在PHP中使用Bigcommerce API。尝试将URL中的图像添加到现有产品中。已经尝试了一段时间,但我无法和他们的文档没有真正解释如何编辑或导入产品图像非常好。
这就是我所拥有的。没有运气。任何帮助将不胜感激!
<?php
error_reporting(E_ALL);
ini_set('display_errors', True);
require 'includes/bigcommerce.php';
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => $url,
'username' => $username,
'api_key' => $key
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
$path = '/product/78/images';
$object = 'http://www.greencoffeelover.com/wp-content/uploads/2015/03/Test-Product.jpg';
Bigcommerce::createResource($path, $object)
?>
答案 0 :(得分:1)
我自己想出来了。
require 'bigcommerce.php';
use Bigcommerce\Api\Client as Bigcommerce;
use Bigcommerce\Api\Resources\ProductImage as ProductImage;
Bigcommerce::configure(array(
'store_url' => $url,
'username' => $username,
'api_key' => $key
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
$new_product_image = new ProductImage();
$new_product_image->product_id = $productID;
$new_product_image->image_file = $png_url;
$new_product_image->is_thumbnail = true;
$new_product_image->description = "";
$product_image = $new_product_image->create();
答案 1 :(得分:0)
您也可以使用第一种方式,只需更改您的$对象:
createProductImage()
或使用$object = array('image_file'=>'http://www.greencoffeelover.com/wp-content/uploads/2015/03/Test-Product.jpg');
Bigcommerce::createProductImage($product_id, $object)
功能:
{{1}}