

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# HTTP/HTTPS 訂閱確認 JSON 格式
<a name="http-subscription-confirmation-json"></a>

在您訂閱 HTTP/HTTPS 端點之後，Amazon SNS 會傳送訂閱確認訊息至 HTTP/HTTPS 端點。此訊息包含 `SubscribeURL` 值，您必須造訪才能確認訂閱 (或者，您可以使用具有 [https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html](https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html) 的 `Token` 值)。

**注意**  
除非已確認訂閱，否則 Amazon SNS 不會傳送通知至此端點

訂閱確認訊息是 POST 訊息，訊息內文包含 JSON 文件及以下名稱值組。

**`Type`**  
訊息的類型。若是訂閱確認，類型為 `SubscriptionConfirmation`。

**`MessageId`**  
全域唯一識別符 (UUID)，對於每個發布的訊息均為唯一。若是 Amazon SNS 在重試期間重送的訊息，會使用原始訊息的訊息 ID。

**`Token`**  
您可以與 [https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html](https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html) 動作搭配使用以確認訂閱。或者，您也可直接造訪 `SubscribeURL`。

**`TopicArn`**  
此端點訂閱之主題的 Amazon Resource Name (ARN)。

**`Message`**  
說明訊息的字串。若是訂閱確認，此字串看起來如下：  

```
You have chosen to subscribe to the topic arn:aws:sns:us-east-2:123456789012:MyTopic.\nTo confirm the subscription, visit the SubscribeURL included in this message.
```

**`SubscribeURL`**  
為了確認訂閱您必須造訪的 URL。或者，您可以改為使用 `Token` 和 [https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html](https://docs.aws.amazon.com/sns/latest/api/API_ConfirmSubscription.html) 動作以確認訂閱。

**`Timestamp`**  
送出確認訂閱的時間 (GMT)。

**`SignatureVersion`**  
Amazon SNS 簽章所使用的版本。  
+ 如果 `SignatureVersion` 為 **1**，則 `Signature` 為 `Message`、`MessageId`、`Type`、`Timestamp` 和 `TopicArn` 值的 Base-64 編碼 `SHA1withRSA` 簽章。
+ 如果 `SignatureVersion` 為 **2**，則 `Signature` 為 `Message`、`MessageId`、`Type`、`Timestamp` 和 `TopicArn` 值的 Base-64 編碼 `SHA256withRSA` 簽章。

**`Signature`**  
以 Base64 編碼 `SHA1withRSA` 或 `Message`、`MessageId`、`Type`、`Timestamp` 和 `TopicArn` 值的 `SHA256withRSA` 簽章。

**`SigningCertURL`**  
用於簽署訊息的憑證的 URL。

以下 HTTP POST 訊息是發至 HTTP 端點的 `SubscriptionConfirmation` 訊息的範例。

```
POST / HTTP/1.1
x-amz-sns-message-type: SubscriptionConfirmation
x-amz-sns-message-id: 165545c9-2a5c-472c-8df2-7ff2be2b3b1b
x-amz-sns-topic-arn: arn:aws:sns:us-west-2:123456789012:MyTopic
Content-Length: 1336
Content-Type: text/plain; charset=UTF-8
Host: myhost.example.com
Connection: Keep-Alive
User-Agent: Amazon Simple Notification Service Agent

{
  "Type" : "SubscriptionConfirmation",
  "MessageId" : "165545c9-2a5c-472c-8df2-7ff2be2b3b1b",
  "Token" : "2336412f37...",
  "TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic",
  "Message" : "You have chosen to subscribe to the topic arn:aws:sns:us-west-2:123456789012:MyTopic.\nTo confirm the subscription, visit the SubscribeURL included in this message.",
  "SubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=ConfirmSubscription&TopicArn=arn:aws:sns:us-west-2:123456789012:MyTopic&Token=2336412f37...",
  "Timestamp" : "2012-04-26T20:45:04.751Z",
  "SignatureVersion" : "1",
  "Signature" : "EXAMPLEpH+DcEwjAPg8O9mY8dReBSwksfg2S7WKQcikcNKWLQjwu6A4VbeS0QHVCkhRS7fUQvi2egU3N858fiTDN6bkkOxYDVrY0Ad8L10Hs3zH81mtnPk5uvvolIC1CXGu43obcgFxeL3khZl8IKvO61GWB6jI9b5+gLPoBc1Q=",
  "SigningCertURL" : "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"
}
```