Facebook 转化 API - AuthorizationException(无效参数)

Facebook Conversions API - AuthorizationException (Invalid parameter)

在支付网关上成功交易并重定向到网站后触发 Purchase 事件时,出现以下错误:

Fatal error: Uncaught FacebookAds\Http\Exception\AuthorizationException: Invalid parameter in /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php:174 Stack trace: #0 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Client.php(215): FacebookAds\Http\Exception\RequestException::create(Object(FacebookAds\Http\Response)) #1 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Request.php(286): FacebookAds\Http\Client->sendRequest(Object(FacebookAds\Http\Request)) #2 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Api.php(165): FacebookAds\Http\Request->execute() #3 /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Api.php(214): FacebookAds\Api->executeRequest(Object(FacebookAds\Http\ in /path/fb-business-sdk/vendor/facebook/php-business-sdk/src/FacebookAds/Http/Exception/RequestException.php on line 174

使用有效的像素 ID 和令牌时未出现任何问题的其他事件被触发。

$this->api = Api::init($pixel_id, null, $access_token);
$event = (new Event())
                ->setActionSource(ActionSource::WEBSITE)
                ->setEventName('Purchase')
                ->setEventTime(time())
                ->setEventSourceUrl($current_url)
                ->setUserData($user_data);
            
$events = array();
array_push($events, $event);
$request = $this->create_request($events);
// Execute the request
$response = $request->execute();

我遇到了同样的问题,但发现出现异常的原因是购买事件必须设置 currencyvalue .

$customData = (new CustomData())
        ->setCurrency('USD')
        ->setValue(10);

然后将自定义数据添加到事件中:

->setCustomData($customData)