使用 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)
?>
最佳答案
我自己想出来的。
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();
关于php - (Bigcommerce API) - 向现有产品添加图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30578477/