在Facebook上批量上传大型目录

时间:2017-06-21 10:41:16

标签: php facebook facebook-graph-api

使用Facebook Marketing API,我需要在目录中创建和更新大量产品。因此,我使用“批量上传大型目录”在我的目录中创建产品。

参考链接:https://developers.facebook.com/docs/marketing-api/dynamic-product-ads/product-catalog#catalog-update-options

我已经安装了最新的“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.

0 个答案:

没有答案