使用 API

完成新手入門頁面所列的必要條件後,在此頁面了解如何傳送事件和使用測試事件工具。傳送事件後,請驗證設定

轉換 API 建基於 Facebook 的推廣 API,而推廣 API 則是根據 Graph API 的基礎開發。推廣 API 和 Graph API 的不同版本會按指定時間停用,但兩者所依照的停用時間表並不同。我們的發佈週期與 Graph API 保持一致,因此每個版本最少可以使用 2 年。此例外情況僅適用於轉換 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": 1732199151, "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 查詢參數,將您產生的安全存取憑證附加到要求中。您亦可以使用 Graph API 測試工具/<pixel_id>/events 端點執行 POST 操作。

要求內文範例如下所示:

{
   "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 的時間。這個做法的目的是允許一次過大量處理和伺服器成效優化。

event_time 最早可以是您向 Meta 傳送事件的 7 天前。如果 data 中的任何 event_time 早於 7 天前,我們會為整個要求傳回錯誤訊息,且不處理任何事件。針對離線事件以及以 physical_store 作為 action_source 的實體商店事件,您應上載發生轉換後 62 天內的交易。

使用轉換 API,即表示您同意 action_source 參數據您所知正確無誤。

批量要求

您最多可以在 data 中傳送 1,000 個事件,但我們建議您儘可能在事件發生後立即傳送事件以獲得最佳效果;在理想情況下,您應在事件發生後一小時內傳送。如果批次傳送中有任何事件無效,整個批次都會遭拒。

雜湊

請查看我們的顧客資訊參數頁面,了解哪些參數應要在傳送到 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 月起,系統已停止支援 PHP 5 Business SDK。請升級至 PHP 7 以使用 Business SDK。

如果您必須使用 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": 1732198551, "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" }

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

您可以使用裝載協助工具來產生此測試裝載。請注意:測試事件代碼僅供測試裝載使用。

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

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

對於應用程式事件 API 和離線轉換 API,可在事件資料參數的每個事件內加入 data_processing_optionsdata_processing_options_countrydata_processing_options_state,以執行資料處理選項。

請注意:對於新的整合,我們不再建議使用應用程式事件 API 和離線轉換 API。建議您改為使用轉換 API,因為轉換 API 現在支援網頁事件、應用程式事件和離線事件。詳情請參閱應用程式事件的轉換 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 有其專屬的限速邏輯,所以不受任何其他 Graph API 限速影響。因此,如果您呼叫推廣 API,此呼叫並不會計入 Graph API 限速。

轉換 API 不設特定的限速限制。轉換 API 呼叫計為推廣 API 呼叫。唯一的限制是最多可以一次過傳送 1,000 個事件。請參閱傳送要求了解更多資訊。

推廣 API 限速

在轉換 API 閘道使用 Business SDK API

本指南會為您導覽 Meta Business SDK 專為轉換 API 閘道用戶而設的各種進階功能。有關轉換 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() function

用來處理每項事件的篩選函數。如果篩選邏輯傳回 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;
}
});