Facebook SDK Marketing API

问题描述 投票:0回答:1

很抱歉,我对Facebook SDK和API很新。我试图使用Facebook本身提供的营销API。

在快速入门中,我遵循了网站本身提供的所有步骤。

它将生成一个示例代码,用于我的简单应用程序。

我遇到了一个错误,我必须更改一行,如下所示,并认为它可能在将来帮助其他人。

如果您遇到一个错误,它告诉您下面已弃用的v2.11检查

由此

$fields = array(
);
$params = array(
   'name' => 'Test Catalog',
);
$product_catalog = (new Business($business_id))->createProductCatalog(
  $fields,
  $params
);

对此

$fields = array(
);
$params = array(
    'name' => 'Test Catalog',
);
$product_catalog = (new Business($business_id))->createOwnedProductCatalog(
   $fields,
   $params
);

现在,继续我的问题。

代码的第二部分如下所示

$fields = array(
);
$params = array(
   'name' => 'Test Feed',
    'schedule' => array('interval' => 'DAILY','url' => 'https://developers.facebook.com/resources/dpa_product_catalog_sample_feed.csv','hour' => '22'),
);
echo json_encode((new ProductCatalog($product_catalog_id))->createProductFeed(
   $fields,
   $params
 )->getResponse()->getContent(), JSON_PRETTY_PRINT);

我对这部分有疑问

)->getResponse()->getContent(), JSON_PRETTY_PRINT);

我得到的错误就是这个

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Call to undefined method FacebookAds\Object\ProductFeed::getResponse()

任何帮助将受到高度赞赏。

php facebook-marketing-api fbsdk
1个回答
0
投票

改变这个:

echo json_encode((new ProductCatalog($product_catalog_id))->createProductFeed(
   $fields,
   $params
 )->getResponse()->getContent(), JSON_PRETTY_PRINT);

为了这:

echo json_encode((new ProductCatalog($id))->createProductFeed(
  $fields,
  $params
)->exportAllData(), JSON_PRETTY_PRINT);
© www.soinside.com 2019 - 2024. All rights reserved.