

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# AWS SDK for PHP バージョン 3 を使用して Amazon EventBridge グローバルエンドポイントにイベントを送信する
<a name="eventbridge-examples"></a>

[Amazon EventBridge グローバルエンドポイント](https://docs.aws.amazon.com//eventbridge/latest/userguide/eb-global-endpoints.html)を使用して、イベント駆動型アプリケーションの可用性と信頼性を向上させることができます。

EventBridge グローバルエンドポイントを[設定](https://docs.aws.amazon.com//eventbridge/latest/userguide/eb-global-endpoints.html#eb-ge-create-endpoint)したら、SDK for PHP を使用してイベントを送信できます。

**重要**  
SDK for PHP で EventBridge グローバルエンドポイントを使用するには、PHP 環境に [AWS Common Runtime (AWS CRT) 拡張機能](guide_crt.md)がインストールされている必要があります。

次の例では、`EventBridgeClient` の [PutEvents](https://docs.aws.amazon.com//aws-sdk-php/v3/api/api-eventbridge-2015-10-07.html#putevents) メソッドを使用して、EventBridge グローバルエンドポイントに単一のイベントを送信します。

```
<?php
/* Send a single event to an existing Amazon EventBridge global endpoint. */
require '../vendor/autoload.php';

use Aws\EventBridge\EventBridgeClient;

$evClient = new EventBridgeClient([
    'region' => 'us-east-1'
]);

$endpointId = 'xxxx123456.xxx';  // Existing EventBridge global endpointId.
$eventBusName = 'default';       // Existing event bus in the us-east-1 Region.

$event =  [
    'Source' => 'my-php-app',
    'DetailType' => 'test',
    'Detail' => json_encode(['foo' => 'bar']),
    'Time' => new DateTime(),
    'Resources' => ['php-script'],
    'EventBusName' => $eventBusName,
    'TraceHeader' => 'test'
];

$result = $evClient->putEvents([
    'EndpointId' => $endpointId,
    'Entries' => [$event]
]);
```

[このブログ記事](https://aws.amazon.com/blogs//compute/introducing-global-endpoints-for-amazon-eventbridge/)には、EventBridge グローバルエンドポイントに関する詳細情報が記載されています。