> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 更新活動

> 更新活動

# 更新活動

設定或更新正在遊玩特定遊戲之使用者的活動。
此 API 可讓遊戲用戶端或伺服器為正在遊玩特定遊戲的使用者設定/更新多人遊戲活動。使用者一開始進行多人遊戲活動時，就必須設定活動。XBOX Live 使用者將能夠訂閱其他使用者 (通常是朋友) 的活動變更，而這些更新會透過 RTA 推送至 XBOX 用戶端。

```http theme={null}
PUT /titles/{titleId}/users/{xuid}/activities
```

<a id="uri-parameters" />

## URI 參數

| 參數 | 位置 | 必要 | 類型 | 描述 |
| - | - | - | - | - |
| titleId | path | TRUE | integer | 傳送要求所針對之遊戲的 titleId。 |
| xuid | path | TRUE | string | 目前要求中所指使用者的 XUID。XUID 以 10 進位整數表示。 |

<a id="request-header" />

## 要求標頭

| 名稱 | 必要 | 類型 | 描述 |
| - | - | - | - |
| Authorization | TRUE | integer | 呼叫端必須以 XBL 3.0 授權格式提供 XToken。例如，Authorization: XBL3.0 x=2553948354698;\<encrypted token>) |
| Content-Type | TRUE | string | ContentType 必須設定為 application/json |

<a id="request-body" />

## 要求本文

| 名稱 | 必要 | 類型 | 描述 |
| - | - | - | - |
| connectionString | TRUE | string | 連線字串是傳遞給連線用戶端以加入遊戲的物件。連線字串通常包含伺服器 IP 等資訊，讓加入的使用者能夠連線。連線字串的長度限制為 512 個字元。 |
| joinRestriction | TRUE | JoinRestriction | 決定誰可以加入目前玩家的設定。 |
| sequenceNumber | TRUE | string | 這是單調遞增數字 (ulong) 的字串表示，用戶端必須在每個要求中傳入。它用來保證活動更新的順序。sequenceNumber 的一個好例子是用戶端的 Unix 時間，因為它保證會遞增。必須大於 0，且不能大於 ulong 的最大值。 |
| currentPlayers | | integer | 在多人遊戲活動中已與使用者一起遊玩的玩家數目。 |
| groupId | | string | 用來將所有參與同一場遊戲的使用者分組的唯一識別碼。 |
| maxPlayers | | integer | 在目前活動中可與此玩家一起遊玩的玩家數目上限。 |
| platform | | [Platform](#platform) | |

<a id="responses" />

## 回應

| 名稱 | 類型 | 描述 |
| - | - | - |
| 204 No Content | | 已成功設定活動。 |
| 400 Bad Request | [ErrorResponse](#errorresponse) | 處理要求時發生錯誤。可能的錯誤碼："RequestValidationError: 要求驗證失敗。"、" AuthorizationError: 不允許呼叫端存取資源。要求過多。" |
| 其他狀態碼 | [ThrottledEntity](#throttledentity) | 要求過多。標頭 Retry-After: integer |

<a id="definitions" />

## 定義

* [ErrorResponse](#errorresponse)
* [JoinRestriction](#joinrestriction)
* [Platform](#platform)
* [SetActivityRequest](#setactivityrequest)
* [ThrottleEntity](#throttleentity)

<a id="errorresponse" />

### ErrorResponse

| 名稱 | 類型 | 描述 |
| - | - | - |
| debugMessage | string | 可用於偵錯、人類可讀的錯誤訊息版本。 |
| errorCode | string | 錯誤碼列舉。 |

<a id="joinrestriction" />

### JoinRestriction

決定誰可以加入目前玩家的設定。

| 名稱 | 類型 | 描述 |
| - | - | - |
| Followed | string | |
| InviteOnly | string | |
| Public | string | |

<a id="platform" />

### Platform

| 名稱 | 類型 | 描述 |
| - | - | - |
| Android | string | |
| IOS | string | |
| Nintendo | string | |
| PlayStation | string | |
| Scarlett | string | |
| Win32 | string | |
| WindowsOneCore | string | |
| XboxOne | string | |

<a id="setactivityrequest" />

## SetActivityRequest

如果在要求中設定了活動的平台，則只能在該平台上加入活動。如果未設定平台，則可在遊戲可供遊玩的所有平台上加入活動。

| 名稱 | 類型 | 描述 |
| - | - | - |
| connectionString | string | 連線字串是傳遞給連線用戶端以加入遊戲的物件。連線字串通常包含伺服器 IP 等資訊，讓加入的使用者能夠連線。連線字串的長度限制為 512 個字元。 |
| currentPlayers | integer | 在多人遊戲活動中已與使用者一起遊玩的玩家數目。 |
| groupId | string | 用來將所有參與同一場遊戲的使用者分組的唯一識別碼。 |
| joinRestriction | [JoinRestriction](#joinrestriction) | 決定誰可以加入目前玩家的設定。 |
| maxPlayers | integer | 在目前活動中可與此玩家一起遊玩的玩家數目上限。 |
| platform | [Platform](#platform) | |
| sequenceNumber | string | 這是單調遞增數字 (ulong) 的字串表示，用戶端必須在每個要求中傳入。它用來保證活動更新的順序。sequenceNumber 的一個好例子是用戶端的 Unix 時間，因為它保證會遞增。必須大於 0，且不能大於 ulong 的最大值。 |

<a id="throttleentity" />

### ThrottledEntity

| 名稱 | 類型 | 描述 |
| - | - | - |
| currentRequests | string | 目前的要求數 - 並行或速率。 |
| debugMessage | string | 可用於偵錯、人類可讀的節流訊息版本。 |
| limitType | string | 限制類型，亦即並行或速率。 |
| maxRequests | string | 允許的最大要求數 - 並行或速率。 |
| periodInSeconds | string | 超過速率或並行限制時所套用的期間 (以秒為單位)。 |
| version | string | 目前的節流合約版本。 |


## Related topics

- [開始使用獎勵廣告。](/zh-TW/services/playfab/economy-monetization/rewarded-ads/quickstart.md)
- [多人遊戲活動 (MPA) 功能概觀](/zh-TW/services/xbox-services/multiplayer/mpa/live-mpa-overview.md)
- [多人遊戲活動的範例程式碼](/zh-TW/services/xbox-services/multiplayer/mpa/how-to/live-mpa-client-how-to.md)
- [XR-064 可加入的遊戲工作階段與線上遊戲](/zh-TW/publishing/certification/xr/xr-064.md)
- [活動](/zh-TW/services/xbox-services/multiplayer/mpa/concepts/live-mpa-activities.md)
