簡體   English   中英

Facebook API獲取廣告帳戶廣告支出

[英]Facebook API Get Ad Account Ad Spend

我正試圖從前一天開始支出特定廣告帳戶的費用。 每當我發出請求時:

    $api = Api::instance();



    $account = new AdAccount('act_<account_id>');

    $params = array(
      'level' => 'account',
      'date_preset' => 'yesterday',
      'fields' => ['spend', 'account_id'],

    );
    $insights = $account->getInsights(array(), $params);

    print_r($insights);

我得到了一個大的受保護對象,似乎找不到有關如何訪問實際請求的數據的任何文檔。

            //Get HLG Ad Spend
        $account = new AdAccount('act_10153795481711178');

        $params = array(
          'level' => 'account',
          'date_preset' => 'yesterday',
          'fields' => ['spend', 'account_id']

        );
        $insights = $account->getInsights(array(), $params);

        $hlgData = $insights->getResponse()->getContent()['data'];
        if(isset($hlgData[0]))
        {
              $hlgSpendFB = $hlgData[0]['spend'];
        }else{
             $hlgSpendFB = "0";
        }

以上是我如何從廣告帳戶獲取數據以進行前一天支出的信息。 在深入研究對象本身之后,我能夠找到用於獲取所請求數據的getter函數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM