使用 API

完成開始使用頁面中的先決條件後,請透過此頁面學習如何傳送事件和使用測試事件工具。傳送事件後,請驗證您的設定

轉換 API 是以 Facebook 的行銷 API 為基礎,而行銷 API 則是依據圖形 API 所建置。行銷 API 與圖形 API 的版本停用時程並不相同,我們的發行週期與圖形 API 的時程一致,因此每個版本受支援的時間均達兩年以上。這個例外情況僅適用於轉換 API。

轉換 API:總覽參數

使用轉換 API 分享的網路、應用程式和實體商店事件需要特定參數。使用轉換 API,即表示您同意 action_source 參數就您所知是正確的。這裡有提供必要參數清單。

傳送要求

若要傳送新事件,請從以下路徑向此 API 的 /events 關係連線發出 POST 要求:https://graph.facebook.com/{API_VERSION}/{PIXEL_ID}/events?access_token={TOKEN}。當您發佈到此關係連線時,Facebook 會建立新的伺服器事件。

curl -X POST \ -F 'data=[ { "event_name": "Purchase", "event_time": 1734848603, "user_data": { "em": [ "309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd" ], "ph": [ "254aa248acb47dd654ca3ea53f48c2c26d641d23d7e2e93a1ec56258df7674c4", "6f4fcb9deaeadc8f9746ae76d97ce1239e98b404efe5da3ee0b7149740f89ad6" ], "client_ip_address": "123.123.123.123", "client_user_agent": "$CLIENT_USER_AGENT", "fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890", "fbp": "fb.1.1558571054389.1098115397" }, "custom_data": { "currency": "usd", "value": 123.45, "contents": [ { "id": "product123", "quantity": 1, "delivery_category": "home_delivery" } ] }, "event_source_url": "http://jaspers-market.com/product/123", "action_source": "website" } ]' \ -F 'access_token=<ACCESS_TOKEN>' \ https://graph.facebook.com/v21.0/<PIXEL_ID>/events
'use strict'; const bizSdk = require('facebook-nodejs-business-sdk'); const Content = bizSdk.Content; const CustomData = bizSdk.CustomData; const DeliveryCategory = bizSdk.DeliveryCategory; const EventRequest = bizSdk.EventRequest; const UserData = bizSdk.UserData; const ServerEvent = bizSdk.ServerEvent; const access_token = '<ACCESS_TOKEN>'; const pixel_id = '<ADS_PIXEL_ID>'; const api = bizSdk.FacebookAdsApi.init(access_token); let current_timestamp = Math.floor(new Date() / 1000); const userData = (new UserData()) .setEmails(['joe@eg.com']) .setPhones(['12345678901', '14251234567']) // It is recommended to send Client IP and User Agent for Conversions API Events. .setClientIpAddress(request.connection.remoteAddress) .setClientUserAgent(request.headers['user-agent']) .setFbp('fb.1.1558571054389.1098115397') .setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890'); const content = (new Content()) .setId('product123') .setQuantity(1) .setDeliveryCategory(DeliveryCategory.HOME_DELIVERY); const customData = (new CustomData()) .setContents([content]) .setCurrency('usd') .setValue(123.45); const serverEvent = (new ServerEvent()) .setEventName('Purchase') .setEventTime(current_timestamp) .setUserData(userData) .setCustomData(customData) .setEventSourceUrl('http://jaspers-market.com/product/123') .setActionSource('website'); const eventsData = [serverEvent]; const eventRequest = (new EventRequest(access_token, pixel_id)) .setEvents(eventsData); eventRequest.execute().then( response => { console.log('Response: ', response); }, err => { console.error('Error: ', err); } );
require __DIR__ . '/vendor/autoload.php'; use FacebookAds\Api; use FacebookAds\Logger\CurlLogger; use FacebookAds\Object\ServerSide\ActionSource; use FacebookAds\Object\ServerSide\Content; use FacebookAds\Object\ServerSide\CustomData; use FacebookAds\Object\ServerSide\DeliveryCategory; use FacebookAds\Object\ServerSide\Event; use FacebookAds\Object\ServerSide\EventRequest; use FacebookAds\Object\ServerSide\UserData; $access_token = '<ACCESS_TOKEN>'; $pixel_id = '<ADS_PIXEL_ID>'; $api = Api::init(null, null, $access_token); $api->setLogger(new CurlLogger()); $user_data = (new UserData()) ->setEmails(array('joe@eg.com')) ->setPhones(array('12345678901', '14251234567')) // It is recommended to send Client IP and User Agent for Conversions API Events. ->setClientIpAddress($_SERVER['REMOTE_ADDR']) ->setClientUserAgent($_SERVER['HTTP_USER_AGENT']) ->setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890') ->setFbp('fb.1.1558571054389.1098115397'); $content = (new Content()) ->setProductId('product123') ->setQuantity(1) ->setDeliveryCategory(DeliveryCategory::HOME_DELIVERY); $custom_data = (new CustomData()) ->setContents(array($content)) ->setCurrency('usd') ->setValue(123.45); $event = (new Event()) ->setEventName('Purchase') ->setEventTime(time()) ->setEventSourceUrl('http://jaspers-market.com/product/123') ->setUserData($user_data) ->setCustomData($custom_data) ->setActionSource(ActionSource::WEBSITE); $events = array(); array_push($events, $event); $request = (new EventRequest($pixel_id)) ->setEvents($events); $response = $request->execute(); print_r($response);
import time from facebook_business.adobjects.serverside.action_source import ActionSource from facebook_business.adobjects.serverside.content import Content from facebook_business.adobjects.serverside.custom_data import CustomData from facebook_business.adobjects.serverside.delivery_category import DeliveryCategory from facebook_business.adobjects.serverside.event import Event from facebook_business.adobjects.serverside.event_request import EventRequest from facebook_business.adobjects.serverside.user_data import UserData from facebook_business.api import FacebookAdsApi access_token = '<ACCESS_TOKEN>' pixel_id = 'ADS_PIXEL_ID>' FacebookAdsApi.init(access_token=access_token) user_data = UserData( emails=['joe@eg.com'], phones=['12345678901', '14251234567'], # It is recommended to send Client IP and User Agent for Conversions API Events. client_ip_address=request.META.get('REMOTE_ADDR'), client_user_agent=request.headers['User-Agent'], fbc='fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890', fbp='fb.1.1558571054389.1098115397', ) content = Content( product_id='product123', quantity=1, delivery_category=DeliveryCategory.HOME_DELIVERY, ) custom_data = CustomData( contents=[content], currency='usd', value=123.45, ) event = Event( event_name='Purchase', event_time=int(time.time()), user_data=user_data, custom_data=custom_data, event_source_url='http://jaspers-market.com/product/123', action_source=ActionSource.WEBSITE, ) events = [event] event_request = EventRequest( events=events, pixel_id=pixel_id, ) event_response = event_request.execute() print(event_response)
import com.facebook.ads.sdk.APIContext; import com.facebook.ads.sdk.APIException; import com.facebook.ads.sdk.serverside.ActionSource; import com.facebook.ads.sdk.serverside.Content; import com.facebook.ads.sdk.serverside.CustomData; import com.facebook.ads.sdk.serverside.DeliveryCategory; import com.facebook.ads.sdk.serverside.Event; import com.facebook.ads.sdk.serverside.EventRequest; import com.facebook.ads.sdk.serverside.EventResponse; import com.facebook.ads.sdk.serverside.UserData; import java.util.Arrays; public class ServerSideApiExample { public static final String ACCESS_TOKEN = "<ACCESS_TOKEN>"; public static final String PIXEL_ID = "<ADS_PIXEL_ID>"; public static void main(String[] args) { APIContext context = new APIContext(ACCESS_TOKEN).enableDebug(true); context.setLogger(System.out); UserData userData = new UserData() .emails(Arrays.asList("joe@eg.com")) .phones(Arrays.asList("12345678901", "14251234567")) // It is recommended to send Client IP and User Agent for Conversions API Events. .clientIpAddress(clientIpAddress) .clientUserAgent(clientUserAgent) .fbc("fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890") .fbp("fb.1.1558571054389.1098115397"); Content content = new Content() .productId("product123") .quantity(1L) .deliveryCategory(DeliveryCategory.home_delivery); CustomData customData = new CustomData() .addContent(content) .currency("usd") .value(123.45F); Event purchaseEvent = new Event(); purchaseEvent.eventName("Purchase") .eventTime(System.currentTimeMillis() / 1000L) .userData(userData) .customData(customData) .eventSourceUrl("http://jaspers-market.com/product/123") .actionSource(ActionSource.website); EventRequest eventRequest = new EventRequest(PIXEL_ID, context); eventRequest.addDataItem(purchaseEvent); try { EventResponse response = eventRequest.execute(); System.out.println(String.format("Standard API response : %s ", response)); } catch (APIException e) { e.printStackTrace(); } } }
require 'facebook_ads' access_token = '<ACCESS_TOKEN>' pixel_id = '<ADS_PIXEL_ID>' FacebookAds.configure do |config| config.access_token = access_token end user_data = FacebookAds::ServerSide::UserData.new( emails: ['joe@eg.com'], phones: ['12345678901', '14251234567'], # It is recommended to send Client IP and User Agent for Conversions API Events. client_ip_address: request.remote_ip, client_user_agent: request.user_agent, fbc: 'fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890', fbp: 'fb.1.1558571054389.1098115397' ) content = FacebookAds::ServerSide::Content.new( product_id: 'product123', quantity: 1, delivery_category: 'home_delivery' ) custom_data = FacebookAds::ServerSide::CustomData.new( contents: [content], currency: 'usd', value: 123.45 ) event = FacebookAds::ServerSide::Event.new( event_name: 'Purchase', event_time: Time.now.to_i, user_data: user_data, custom_data: custom_data, event_source_url: 'http://jaspers-market.com/product/123', action_source: 'website' ) request = FacebookAds::ServerSide::EventRequest.new( pixel_id: pixel_id, events: [event] ) print request.execute

使用 access_token 查詢參數將產生的安全存取權杖附加到要求。您也可使用圖形 API 測試工具POST/<pixel_id>/events 端點。

要求範例的主體看起來如下所示:

{
   "data": [
      {
         "event_name": "Purchase",
         "event_time": 1633552688,
         "event_id": "event.id.123",
         "event_source_url": "http:\/\/jaspers-market.com\/product\/123",         
         "action_source": "website",
         "user_data": {
            "client_ip_address": "192.19.9.9",
            "client_user_agent": "test ua",
            "em": [
               "309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd"
            ],
            "ph": [
               "254aa248acb47dd654ca3ea53f48c2c26d641d23d7e2e93a1ec56258df7674c4",
               "6f4fcb9deaeadc8f9746ae76d97ce1239e98b404efe5da3ee0b7149740f89ad6"
            ],
            "fbc": "fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890",
            "fbp": "fb.1.1558571054389.1098115397"
         },
         "custom_data": {
            "value": 100.2,
            "currency": "USD",
            "content_ids": [
               "product.id.123"
            ],
            "content_type": "product"
         },
         "opt_out": false
      },
      {
         "event_name": "Purchase",
         "event_time": 1633552688,
         "user_data": {
            "client_ip_address": "192.88.9.9",
            "client_user_agent": "test ua2"
         },
         "custom_data": {
            "value": 50.5,
            "currency": "USD"
         },
         "opt_out": false
      }
   ]
}

上傳時間與事件交易時間

event_time 是事件交易時間,應以 Unix 時間戳記的形式(以秒為單位)傳送,指示實際事件發生的時間。指定的時間可能會早於您向 Facebook 傳送事件的時間,這是為了能夠進行批次處理和達到伺服器效能最佳化。

在您向 Meta 傳送事件之前,event_time 最多可達 7 天。如果 data 中的任何 event_time 在過去大於 7 天,我們會針對整個要求傳回錯誤,且不會處理任何事件。若是將 physical_store 作為 action_source 的離線和實體商店事件,您應在轉換後的 62 天內上傳交易。

使用轉換 API,即表示您同意 action_source 參數就您所知是正確的。

批次要求

您最多可以在 data 中傳送 1,000 個事件。如要確保最佳效能,建議您在事件發生後立即傳送事件,最好是在事件發生後的一小時內傳送。如果您在批次中傳送的任何事件無效,我們會拒絕整個批次。

雜湊

如需瞭解哪些參數應先進行雜湊再傳送至 Facebook,請參閱顧客資訊參數頁面。如果您是使用 Facebook 的其中一個 Business SDK,則 SDK 會直接為您進行雜湊。

適用於轉換 API 的 Business SDK 功能

深入瞭解專為轉換 API 用戶設計的三項特定 Business SDK 功能:非同步要求並行批次HTTP 服務介面。使用這些功能所需的最低語言版本:

  • PHP >= 7.2
  • Node.js >= 7.6.0
  • Java >= 8
  • Python >= 2.7
  • Ruby >= 2

自 2019 年 1 月起,Business SDK 已不再支援 PHP 5。若要使用 Business SDK,請升級至 PHP 7。

如果您必須使用 PHP 5,則建議使用 Swagger 整合

轉換 API 參數

驗證事件

傳送事件後,您可以在事件管理工具中確認我們已收到這些事件,步驟如下:

  • 前往資料來源頁面,在 POST 要求中點擊與 PIXEL_ID 對應的像素。如需詳細資訊,請參閱企業商家使用說明:瀏覽事件管理工具
  • 接著,點擊總覽。畫面上隨即會顯示我們收到的原始事件、相符事件與歸因事件。在連線方法底下,您可以查看傳送該事件的管道。
  • 如需具體詳情,則可點擊每個事件。
  • 開始傳送事件後,您應可在 20 分鐘內驗證事件。現在,您可以開始從伺服器傳送事件。

測試事件工具

您可以使用事件管理工具中的測試事件功能,驗證 Facebook 是否已正確接收伺服器事件。若要尋找工具,請前往 Events Manager > Data Sources > Your Pixel > Test Events

測試事件工具會產生測試編號。將測試編號作為 test_event_code 參數傳送,可以開始看到「測試事件」視窗中顯示的事件活動。

注意test_event_code 欄位應僅作為測試之用。傳送生產承載時,必須將其移除。

系統不會取消使用 test_event_code 傳送的事件。它們會流入事件管理工具,並作為目標設定和廣告成效衡量用途。

以下是應該如何建構要求的範例:

{ "data": [ { "event_name": "ViewContent", "event_time": 1734848003, "event_id": "event.id.123", "event_source_url": "http:\/\/jaspers-market.com", "user_data": { "client_ip_address": "1.2.3.4", "client_user_agent": "test user agent" } } ], "test_event_code": "TEST123" }

以下範例顯示的是要求在圖形 API 測試工具中的呈現方式:

您可以使用裝載協助工具產生此測試裝載。請注意,測試事件程式碼僅用於測試裝載。

傳送要求後,「測試事件」視窗就會顯示伺服器事件。

適用於美國用戶的資料處理選項

針對這兩個 API,請於事件之 data 參數中的每個事件內新增 data_processing_optionsdata_processing_options_countrydata_processing_options_state 來實作資料處理選項。

注意:新整合不再建議使用應用程式事件及離線轉換 API。改為建議您使用轉換 API,因其現在支援 Web、應用程式及離線事件。請參閱應用程式事件適用的轉換 API離線事件適用的轉換 API 取得更多資訊。

若要明確「不」啟用「限制資料使用(LDU)」,應針對每個事件指定空白陣列,或者直接移除承載中的欄位:

{
    "data": [
        {
            "event_name": "Purchase",
            "event_time": <EVENT_TIME>,
            "user_data": {
                "em": "<EMAIL>"
            },
            "custom_data": {
                "currency": "<CURRENCY>",
                "value": "<VALUE>"
            },
            "data_processing_options": []
        }
    ]
}

若要啟用 LDU 並且讓 Meta 指定地理位置:

{
    "data": [
        {
            "event_name": "Purchase",
            "event_time": <EVENT_TIME>,
            "user_data": {
                "em": "<EMAIL>",
                "client_ip_address": "256.256.256.256"
            },
            "custom_data": {
                "currency": "<CURRENCY>",
                "value": "<VALUE>"
            },
            "data_processing_options": ["LDU"],
            "data_processing_options_country": 0,
            "data_processing_options_state": 0
        }
    ]
}

若要啟用 LDU 並手動指定位置,例如:針對加州:

{
    "data": [
        {
            "event_name": "Purchase",
            "event_time": <EVENT_TIME>,
            "user_data": {
                "em": "<EMAIL>"
            },
            "custom_data": {
                "currency": "<CURRENCY>",
                "value": "<VALUE>"
            },
            "data_processing_options": ["LDU"],
            "data_processing_options_country": 1,
            "data_processing_options_state": 1000
        }
    ]
}

手動上傳用戶介面

離線轉換 API 提供從 .csv 檔案手動上傳事件的選項。在此情況中,請將「資料處理選項」、「資料處理國家/地區」和「資料處理州/省」新增為檔案內的欄位。有關此方面的詳細資訊,請參閱上傳用戶介面。


深入瞭解資料處理選項

API 限制

行銷 API 有自己的限速邏輯,並且獨立於所有圖形 API 速率限制外。因此,如果您發出行銷 API 呼叫,並不會計入圖形 API 限速內。

轉換 API 沒有特定的速率限制。轉換 API 呼叫會以行銷 API 呼叫計算。唯一的限制是,您一次最多可向我們傳送 1,000 個事件。請參閱傳送要求瞭解更多資訊。

行銷 API 限速

在轉換 API 閘道中使用 Business SDK API

本指南旨在協助您運用專為轉換 API 閘道用戶設計的 Meta Business SDK 進階功能。若要瞭解基本的轉換 API 閘道用法,請參閱轉換 API 閘道說明文件

將事件傳送至轉換 API 閘道執行個體

必備條件

您必須先安裝 Meta Business SDK,才能使用下列任一功能。詳情請參閱 Meta Business SDK 新手指南,或是按照下列網址中的 README 指示操作:

這些功能目前僅適用於 PHP 和 Java Business SDK,其他語言版本將在 2023 年底前建置完成。

使用這些功能所需的最低語言版本如下所示:

PHP >= 7.2

Java >= 8

請注意:若要刪除重複的事件並傳送到轉換 API 端點,請在要求中傳遞 eventId。這樣在轉換 API 發佈功能為啟用的情況下,系統就不會顯示重複的事件。

格式化 CAPIGatewayIngressRequest 參數

參數說明
endpointUrl
字串

接收事件的轉換 API 閘道端點。系統只會檢查該參數是否為有效的網址,而不會執行其他預先驗證操作。


範例:https://test.example.com


accessKey
字串

將事件傳送至轉換 API 閘道事件端點時所需的轉換 API 閘道存取密鑰。若要產生該密鑰,請參閱相關指示

CAPIGatewayIngressRequest Setter

參數說明
setSendToDestinationOnly
布林值

布林值旗標,註明事件是否只能傳送至所選端點。


預設值:False


setFilter
CustomEndpointRequest.Filter() 函數

用來處理每個事件的篩選函數。如果篩選邏輯傳回 true,事件就能成功傳遞,否則事件將遭到捨棄。請務必在具備參數 Event 的介面中實作 shouldSendEvent 函數。


預設值:Null



移轉範例:PHP

如果系統目前已使用 Business SDK,您只需參照新的 CAPIGatewayIngressRequest,並將該要求附加至 eventRequest 的 customEndpoint 物件即可。

// this is the standard event request that we attach events to
$event_request = new EventRequest($this->pixel_id);
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$event_request->setCustomEndpoint($capiIngressRequest);
// pass the events to this event Request object
$event_request->setEvents($events);
$event_request->execute()

移轉範例:Java

如果系統目前已使用 Business SDK,您只需參照新的 CAPIGatewayIngressRequest,並將該要求附加至 eventRequest 的 customEndpoint 物件即可。

// this is the standard event request that we attach events to


EventRequest eventRequest = new EventRequest(PIXEL_ID, context);


CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
eventRequest.setCustomEndpoint(capiSyncRequest);
eventRequest.addDataItem(testEvent);
eventRequest.execute();

同步選項

PHP 程式碼範例

$api = Api::init(null, null, $this->access_token);
$api->setLogger(new CurlLogger());
$event_request = new EventRequest($this->pixel_id);
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$event_request->setCustomEndpoint($capiIngressRequest);
$user_data = (new UserData())
   ->setEmails(array('joe@eg.com'))
   ->setPhones(array('12345678901', '14251234567'))
   ->setFbc('fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890')
   ->setFbp('fb.1.1558571054389.1098115397');
$event1 = (new Event())
   ->setEventName('Purchase')
   ->setEventId('125')
   ->setEventTime(time())
   ->setEventSourceUrl('http://jaspers-market.com/product/123')
   ->setUserData($user_data);
$events = array($event1, $event2);
$event_request->setEvents($events);
$response = $event_request->execute();
print($response->__toString());

Java 程式碼範例

EventRequest eventRequest = new EventRequest(PIXEL_ID, context);
UserData userData = new UserData()
       .email("abc@eg.com");
CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
eventRequest.setCustomEndpoint(capiSyncRequest);
Event testEvent = new Event();
testEvent.eventId("125").eventName("Purchase")
       .eventTime(System.currentTimeMillis() / 1000L)
       .userData(userData)
       .dataProcessingOptions(new String[]{}).setEventId("134423232");
eventRequest.namespaceId("11")
       .uploadId("22222")
       .uploadTag("upload-tag-4")
       .uploadSource("upload-source-4")
       .testEventCode("test-event-code-5")
       .partnerAgent("partner-agent-6");
eventRequest.addDataItem(testEvent);
eventRequest.execute();

非同步選項

PHP 程式碼範例

$api = Api::init(null, null, $this->access_token);
$api->setLogger(new CurlLogger());
$event_request = new EventRequestAsync($this->pixel_id);
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$capiIngressRequest->setSendToDestinationOnly(true);
$event_request->setCustomEndpoint($capiIngressRequest);
$event1 = (new Event())
   ->setEventName('test Async Event')
   ->setEventId('134423232')
   ->setEventTime(time())
   ->setEventSourceUrl('http://jaspers-market.com/product/123');
$events = array($event1, $event2);
$event_request->setEvents($events);
$response = $event_request->execute()->wait();

Java 程式碼範例

EventRequest eventRequest = new EventRequest(PIXEL_ID, context);
UserData userData = new UserData()
       .email("abc@eg.com");
CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
capiSyncRequest.setSendToDestinationOnly(true);
eventRequest.setCustomEndpoint(capiSyncRequest);
Event testEvent = new Event();
testEvent.eventName("test Async Event")
       .eventTime(System.currentTimeMillis() / 1000L)
       .userData(userData)
       .dataProcessingOptions(new String[]{}).setEventId("134423232");
eventRequest.namespaceId("11222")
       .uploadId("22222")
       .uploadTag("upload-tag-4")
       .uploadSource("upload-source-4")
       .testEventCode("test-event-code-5")
       .partnerAgent("partner-agent-6");
eventRequest.addDataItem(testEvent);
eventRequest.executeAsync();

篩選功能

PHP 程式碼範例

lass APIFilter implements Filter {
   public function shouldSendEvent(Event $event): bool
   {
       if ($event->getEventId() === '125') {
           return false;
       }
       return true;
   }
}
$capiIngressRequest = new CAPIGatewayIngressRequest($this->cb_url, $this->access_key);
$event_request->setCustomEndpoint($capiIngressRequest);
$capiIngressRequest->setFilter(new APIFilter());

Java 程式碼範例

CAPIGatewayIngressRequest capiSyncRequest = new CAPIGatewayIngressRequest(CB_URL, CAPIG_ACCESS_KEY);
eventRequest.setCustomEndpoint(capiSyncRequest);


capiSyncRequest.setFilter(new CustomEndpointRequest.Filter() {
   @Override
   public boolean shouldSendEvent(Event event) {
   if (event.getEventId().equals("125")) {
       return true;
   }
   return false;
}
});