> ## 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.

# GET (/users/xuid({xuid}))

> GET (/users/xuid({xuid}))

# GET (/users/xuid({xuid}))

查询另一位用户或客户端的在线状态。
这些 URI 的域为 `userpresence.xboxlive.com`。

* [备注](#ID4EV)
* [URI 参数](#ID4EDB)
* [查询字符串参数](#ID4EOB)
* [授权](#ID4E4C)
* [隐私设置对资源的影响](#ID4EAE)
* [必需的请求标头](#ID4EVH)
* [可选的请求标头](#ID4E1BAC)
* [请求正文](#ID4E1CAC)
* [响应正文](#ID4EFDAC)

## 备注

如果使用者对整个对象不感兴趣,可以对响应进行筛选以仅提供部分 [PresenceRecord](https://devdocs.xbox.com/zh-CN/reference/live/rest/json/json-presencerecord)。

> **注意:**\
> 返回的数据受隐私和内容隔离规则的约束。

## URI 参数

\| 参数 | 类型 | 说明 |
\| --- | --- | --- | --- |
\| xuid | 64 位无符号整数 | 目标用户的 XBOX 用户 ID (XUID)。 |

## 查询字符串参数

\| 参数 | 类型 | 说明 |
\| --- | --- | --- | --- | --- | --- | --- |
\| level | string | 可选。<ul><li>**user**:仅返回用户节点。</li><li>**device**:返回用户节点和设备节点。</li><li>**title**:默认。返回除活动外的整个树。</li><li>**all**:返回整个树,包括活动级在线状态。</li></ul> |

## 授权

\| 类型 | 是否必需 | 说明 | 缺失时的响应 |
\| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
\| XUID | 是 | 调用方的 XBOX 用户 ID (XUID) | 403 Forbidden |

## 隐私设置对资源的影响

此方法始终返回 200 OK,但可能不会在响应正文中返回内容。

\| 请求用户 | 目标用户的隐私设置 | 行为 |
\| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
\| me | - | 200 OK |
\| friend | everyone | 200 OK |
\| friend | friends only | 200 OK |
\| friend | blocked | 200 OK |
\| non-friend user | everyone | 200 OK |
\| non-friend user | friends only | 200 OK |
\| non-friend user | blocked | 200 OK |
\| third-party site | everyone | 200 OK |
\| third-party site | friends only | 200 OK |
\| third-party site | blocked | 200 OK |

## 必需的请求标头

\| 标头 | 类型 | 说明 |
\| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
\| Authorization | string | HTTP 身份验证的身份验证凭据。示例值:"XBL3.0 x=\<userhash>;\<token>"。 |
\| x-xbl-contract-version | string | 此请求应指向的 XBOX LIVE 服务的生成名称/编号。仅在验证标头的有效性、身份验证令牌中的声明等的有效性之后,请求才会路由到该服务。示例值:3、vnext。 |
\| Accept | string | 可接受的 Content-Type。在线状态服务仅支持 application/json,但必须在标头中指定。 |
\| Accept-Language | string | 响应中字符串的可接受区域设置。示例值:en-US。 |
\| Host | string | 服务器的域名。示例值:presencebeta.xboxlive.com。 |

## 可选的请求标头

\| 标头 | 类型 | 说明 |
\| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
\| X-RequestedServiceVersion |  | 此请求应指向的 XBOX LIVE 服务的生成名称/编号。仅在验证标头的有效性、身份验证令牌中的声明等的有效性之后,请求才会路由到该服务。默认值:1。 |

## 请求正文

此请求正文中未发送任何对象。

## 响应正文

### 示例响应

如果该用户没有现有记录,则返回一条不含设备的记录。

```json theme={null}
{
  xuid:"0123456789",
  state:"online",
  devices:
  [{
    type:"D",
    titles:
    [{
      id:"12341234",
      name:"Contoso 5",
      state:"active",
      placement:"fill",
      timestamp:"2012-09-17T07:15:23.4930000",
      activity:
      {
        richPresence:"Team Deathmatch on Nirvana"
      }
    },
    {
      id:"12341235",
      name:"Contoso Waypoint",
      timestamp:"2012-09-17T07:15:23.4930000",
      placement:"snapped",
      state:"active",
      activity:
      {
        richPresence:"Using radar"
      }
    }]
  },
  {
    type:W8,
    titles:
    [{
      id:"23452345",
      name:"Contoso Gamehelp",
      state:"active",
      placement:"full",
      timestamp:"2012-09-17T07:15:23.4930000",
      activity:
      {
        richPresence:"Nirvana page",
      }
    }]
  }]
}

```

## 另请参阅

##### 父主题

[/users/xuid({xuid})](https://devdocs.xbox.com/zh-CN/reference/live/rest/uri/presence/uri-usersxuid)


## Related topics

- [XblUserStatisticsGetSingleUserStatisticAsync](https://devdocs.xbox.com/ja-jp/reference/live/xsapi-c/user_statistics_c/functions/xbluserstatisticsgetsingleuserstatisticasync.md)
- [XblUserStatisticsGetSingleUserStatisticsAsync](https://devdocs.xbox.com/ja-jp/reference/live/xsapi-c/user_statistics_c/functions/xbluserstatisticsgetsingleuserstatisticsasync.md)
