使用Facebook Marketing API,我需要在目录中创建和更新大量产品。因此,我使用“批量上传大型目录”在我的目录中创建产品。
我已经安装了最新的“Facebook-php-ads-sdk”并从我的Facebook帐户创建了一个测试目录。
use FacebookAds\Api;
use FacebookAds\Http\RequestInterface;
$catalogID = <<My Catalog ID>>; // Ex: 437777777777777 - Product Catalog ID
of My Estore
$requests = array(
array(
'method' => 'CREATE',
'retailer_id' => 'retailer-product-id-123',
'data' => array(
'availability' => 'in stock',
'brand' => 'Niky',
'category' => 't-shirts',
'currency' => 'USD',
'description' => 'This is the product description.',
'image_url' => 'http://www.images.example.com/t-shirts/1.png',
'name' => 'My product name',
'price' => '100',
'url' => 'http://www.example.com/t-shirts/1.html',
),
),
);
$data = Api::instance()->call(
'/'.$catalogID.'/batch',
RequestInterface::METHOD_POST,
array('requests' => $requests))->getContent();
当我将目录ID与上述代码集成时,我收到错误,产品未添加到我的目录中。
发生错误:
Fatal error: Uncaught exception 'FacebookAds\Http\Exception\AuthorizationException' with message 'Unsupported post request. Object with ID '437777777777777' does not exist, cannot be loaded due to missing permissions, or does not support this operation.