营销API许可例外

问题描述:

我需要使用Marketing Api获得一些自动化的广告见解。为此,我通过业务管理器创建了系统用户,并生成了具有ads_read权限的系统用户访问令牌。营销API许可例外

使用此令牌,然后调用API,并得到一个特定的广告系列的见解,与FacebookAds PHP V2.6 SDK,我得到以下错误:

Uncaught exception 'FacebookAds\Http\Exception\PermissionException' 
with message '(#275) Cannot determine the target object for this 
request. Currently supported objects include ad account, business 
account and associated objects.' 

难道我的应用程序需要被列入白名单或者是我缺少别的东西?我注意到,在'ads_read'权限旁边有这样一条说明'(您的应用必须列入白名单)'。

这里是我使用

<?php 

define('VENDOR_DIR', 'vendor/'); // Path to the Vendor directory 
$loader = require VENDOR_DIR.'autoload.php'; 

use FacebookAds\Api; 
use FacebookAds\Object\Campaign; 
// Initialize a new Session and instantiate an Api object 
Api::init(
    'xxxxxxxxxxxxxxxx', // App ID 
    'xxxxxxxxxxxxxxxxx', 
    'xxxxxxxxxxxxxxxxxx' // System User Access Token 
); 

$api = Api::instance(); 

use FacebookAds\Object\Values\InsightsLevels; 

$campaign = new Campaign('xxxxxxxxxxxxx'); 

$params = array(
    'level' => InsightsLevels::CAMPAIGN, 
); 

$async_job = $campaign->getInsightsAsync(array(), $params); 

$async_job->read(); 

while (!$async_job->isComplete()) { 
    sleep(1); 
    $async_job->read(); 
} 

$async_job->getResult(); 

?> 
+0

看起来像您尝试使用的广告系列ID在此处无效 –

+0

感谢您回复@PaulBain!我使用了以下网址中'ids'字段后面显示的ID。此网址是我在查看我的广告时看到的网址。我还使用广告管理系统启用了广告系列ID显示,我可以确认它们是确切的数字。 busineyadayada/act = yyyyyyyyyyyyyyyy&pid = y&ids = xxxxxxxxx&business_id = yyyy –

示例代码好像你的应用程序没有ads_read权限。在这里您可以找到更多关于如何索取的信息:​​