2016-05-31 67 views
0

我需要使用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 –

回答

0

示例代碼好像你的應用程序沒有ads_read權限。在這裏您可以找到更多關於如何索取的信息:​​