簡體   English   中英

使用見解 Facebook 營銷 api (php) 的持續錯誤

[英]constant errors using insights Facebook marketing api (php)

當我嘗試通過 xampp 在本地運行我的應用程序時出現此錯誤。 請注意,我使用來自developers.facebook的快速啟動生成了代碼,因此代碼本身不應該有錯誤。

注意:使用未定義的常量 STDOUT - 在第 83 行的 C:\\xampp\\htdocs\\working\\vendor\\facebook\\php-ads-sdk\\src\\FacebookAds\\Logger\\CurlLogger.php 中假定為“STDOUT”

警告:fwrite() 期望參數 1 是資源,字符串在 C:\\xampp\\htdocs\\working\\vendor\\facebook\\php-ads-sdk\\src\\FacebookAds\\Logger\\CurlLogger.php 中給出,第 182 行

致命錯誤:未捕獲的異常 'FacebookAds\\Http\\Exception\\AuthorizationException' 帶有消息 '(#100) 過濾字段 delivery_info 無效。 有關有效過濾器,請參閱文檔https://developers.facebook.com/docs/marketing-api/insights 在 C:\\xampp\\htdocs\\working\\vendor\\facebook\\php-ads-sdk\\src\\FacebookAds\\Http\\Exception\\RequestException.php:144 堆棧跟蹤:#0 C:\\xampp\\htdocs\\working\\vendor\\facebook \\php-ads-sdk\\src\\FacebookAds\\Http\\Client.php(215): FacebookAds\\Http\\Exception\\RequestException::create(Object(FacebookAds\\Http\\Response)) #1 C:\\xampp\\htdocs\\working \\vendor\\facebook\\php-ads-sdk\\src\\FacebookAds\\Http\\Request.php(282): FacebookAds\\Http\\Client->sendRequest(Object(FacebookAds\\Http\\Request)) #2 C:\\xampp\\htdocs \\working\\vendor\\facebook\\php-ads-sdk\\src\\FacebookAds\\Api.php(162): FacebookAds\\Http\\Request->execute() #3 C:\\xampp\\htdocs\\working\\vendor\\facebook\\php -ads-sdk\\src\\FacebookAds\\Api.php(204): FacebookAds\\Api->executeRequest(Object(FacebookAds\\Http\\Request)) #4 C:\\xampp\\htdocs\\working\\vendor\\facebo in C:\\ xampp\\htdocs\\working\\vendor\\facebook\\php-ads-sdk\\src\\FacebookAds\\Http\\Exception\\RequestException.php 第 144 行

我開始懷疑我從作曲家那里得到了錯誤的文件。 或者我的設置可能有問題。 在我運行 composer.phar 之前,我的 composer.json 的內容是

{ "require": { "facebook/php-sdk-v4": "~5.0", "facebook/php-ads-sdk": "2.10.*" } }

我將附上下面的代碼,以防你們也想看。 我在那里修改的唯一一件事是添加 app_id,因為它沒有包含在生成的代碼中。

 <?php require __DIR__ . '/vendor/autoload.php'; use FacebookAds\\Object\\AdAccount; use FacebookAds\\Object\\AdsInsights; use FacebookAds\\Api; use FacebookAds\\Logger\\CurlLogger; $app_id = '274807576345457'; $access_token = 'EAAD575ZC4O3EBAChoTmxC0nwdbvjXLRUKGGXgmZA6HZBFjmKZB6F3olMIe2mG2dgQSb9SudtN7EeeO8gzo7zgFZB0EHZAwTrg4wsIKsJxB3bhw5fonZC3YCZA0C4InaCSOgW42i4PswQa3BZCctMZBYTh94TwGLxGg8gZAZAj4zZC5PfgXl0kw6eOuxW4g1L41NOwtRDGS7O7FsJZBWZCM0IAe00WSf'; $ad_account_id = 'act_113902719358005'; $app_secret = 'aeb42f19e0f33f0937c023fff12909c4'; $api = Api::init($app_id, $app_secret, $access_token); $api->setLogger(new CurlLogger()); $fields = array( 'cost_per_result', 'cost_per_total_action', 'cpm', 'cpp', 'frequency', 'impressions', 'impressions_auto_refresh', 'impressions_gross', 'reach', 'relevance_score:score', 'relevance_score:positive_feedback', 'relevance_score:negative_feedback', 'result_rate', 'results', 'social_impressions', 'social_reach', 'spend', 'today_spend', 'total_actions', 'total_unique_actions', 'actions:video_view', 'video_10_sec_watched_actions:video_view', 'delivery', ); $params = array( 'level' => 'campaign', 'filtering' => array(array('field' => 'delivery_info','operator' => 'IN','value' => array('active','limited'))), 'breakdowns' => array(), 'time_range' => array('since' => '2017-09-28','until' => '2017-09-29'), ); echo json_encode((new AdAccount($ad_account_id))->getInsights( $fields, $params )->getResponse()->getContent(), JSON_PRETTY_PRINT);

如果評論這部分

[json_encode((new AdAccount($ad_account_id))->getInsights(
  $fields,
  $params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);]

; 錯誤停止。

if make [var_export((new AdAccount($ad_account_id));]顯示完整數組

我遇到了完全相同的錯誤。 我相信(就我而言)這是因為我還使用了較舊的 PHP 版本 (5.6),導致了一些兼容性問題。

我通過在 composer.json 中將 php-ads-sdk 的版本從 2.8 更改為“8.*”(或根據您閱讀此解決方案的時間將其更改為任何最新版本)來解決此問題。

然后在終端中調用sudo composer update

現在我得到這個錯誤。

使用未定義的常量STDOUT-在第83行的C:\\ xampp \\ htdocs \\ diy \\ facebook_sdk \\ vendor \\ facebook \\ php-ads-sdk \\ src \\ FacebookAds \\ Logger \\ CurlLogger.php中假定為“ STDOUT”

暫無
暫無

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

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