首页 > 解决方案 > Fabebook 像素测试服务器事件

问题描述

我正在尝试使用 Graph API 测试 Facebook 像素的服务器事件。我收到了这个回复。

 {
  "error": {
    "message": "Invalid parameter",
    "type": "OAuthException",
    "code": 100,
    "error_subcode": 2804019,
    "is_transient": false,
    "error_user_title": "Server Side Api Parameter Error",
    "error_user_msg": "Unexpected key \"email\" on param \"$['data'][0]\".",
    "fbtrace_id": "Ajfq0hd3gzSkADpWdh9210O"
  }
}

谁能帮我解决我做错了什么?

标签: facebook-graph-apifacebook-pixel

解决方案


,test_event_code应该以相同的令牌方式发送。

php示例:

<?php
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://graph.facebook.com/v12.0/YOUR_PIXEL_ID/events',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('data' => '[{"event_name": "CompleteRegistration","event_id": "ev.123","event_time": "1633709956","action_source": "website", "user_data": {"client_ip_address": "70.80.XXX.XXX","client_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1"},"custom_data": {"currency": "USD","value": 0.5,"websiteurl": "megaodds.net"}}]','access_token' => 'YOUR_TOKEN','test_event_code' => 'TEST86091'),
));

$response = curl_exec($curl);

curl_close($curl);

echo $response;

推荐阅读