Using Facebook Marketing API, I need to Create and Update large quantity of products in the Catalog. So I am using "Batch Upload for Large Catalogs" for creating products in my catalog.
Reference Link: https://developers.facebook.com/docs/marketing-api/dynamic-product-ads/product-catalog#catalog-update-options
I have installed the latest "Facebook-php-ads-sdk" and created a test catalog from my Facebook account.
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();
When I integrated the Catalog ID with the above code, I am receiving the error and the products are not added to my catalog.
Error Occurred:
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.