Steamworks 文献库
IGameNotificationsService 接口
这是用于与游戏通知交互的接口。

注意: 这是服务接口,此接口中的方法应使用 input_json 参数调用。

请参见 Web API 概览,进一步了解 Steamworks Web API。

CreateSession

POST https://partner.steam-api.com/IGameNotificationsService/CreateSession/v1/
名称类型是否必需描述
keystringSteamworks Web API 发行商验证密钥。
appiduint32要为其创建会话的 App ID。
contextuint64游戏指定的上下文值,可供游戏用于将会话与其后端的某个对象相关联。
title{message}在各用户的会话列表中显示的会话标题。
users{message}会话中所有用户的初始状态。
steamiduint64(可选)为其发起请求的 Steam ID。若指定,该用户必须在会话中,且加入会话的所有用户必须为该用户的好友。

为请求中指定的玩家创建全新异步会话。

此 API 调用返回的唯一会话 ID 将用于引用游戏通知 API 中的其他调用,因此应与此游戏的游戏会话状态一起存储。

注意: 此调用需要发行商 API 密钥以使用此方法。 因此,此 API 必须通过安全服务器调用,且绝不能由客户端直接调用!

响应示例:
{ "response": { "sessionid": "10" } }

调用示例:
{ "context": "31415926" "title": { "token": "#MyToken", "variables": [ { "key": "username", "value": "SteamUser" } ] }, "users": [ { "steamid": "76561197960265729", "state": "waiting", "title": { "token": "#TitleToken", "variables": [ { "key": "username", "value": "Bob" } { "key": "level", "value": "1" } ] }, "message": { "token": "#StatusMessageToken", "variables": [ { "key": "city", "value": "Bellevue" } ] } } ] }

UpdateSession

POST https://partner.steam-api.com/IGameNotificationsService/UpdateSession/v1/
名称类型是否必需描述
keystringSteamworks Web API 发行商验证密钥。
sessioniduint64要更新的 sessionid。
appiduint32要更新的会话的 App ID。
title{message}(可选)会话的新标题。 若未指定,标题将不变。
users{message}(可选)用户列表,这些用户的状态将更新以反映给定状态。 如果有用户尚不在会话中,会将其加入会话。
steamiduint64(可选)为其发起请求的 Steam ID。若指定,该用户必须在会话中,且加入会话的所有用户必须为该用户的好友。

每当游戏状态发生更改时,更新游戏会话。

务必相应地更新各用户的状态。这里发送的信息将反映在所有参与游戏的用户收到的通知中。 之前在会话中但这次未列出的用户将被移出会话,任何新列出的用户将会加入会话。 您必须发送会话的完整状态信息。之前的状态会完全被新给出的状态替代。

注意: 此调用需要发行商 API 密钥以使用此方法。 因此,此 API 必须通过安全服务器调用,且绝不能由客户端直接调用!

响应示例:
{ "response": { } }

调用示例:
{ "sessionid": "1234", "title": { "token": "#MyToken", "variables": [ { "key": "username", "value": "SteamUser" } ] }, "users": [ { "steamid": "76561197960265729", "state": "waiting", "title": { "token": "#TitleToken", "variables": [ { "key": "username", "value": "Bob" } { "key": "level", "value": "1" } ] }, "message": { "token": "#StatusMessageToken", "variables": [ { "key": "city", "value": "Bellevue" } ] } }, { "steamid": "76561197960265730", "state": "waiting", "title": { "token": "#TitleToken", "variables": [ { "key": "username", "value": "Greg" } { "key": "level", "value": "2" } ] }, "message": { "token": "#StatusMessageToken", "variables": [ { "key": "city", "value": "Seattle" } ] } } ] }

EnumerateSessionsForApp

GET https://partner.steam-api.com/IGameNotificationsService/EnumerateSessionsForApp/v1/
名称类型是否必需描述
keystringSteamworks Web API 发行商验证密钥。
appiduint32要请求其详情的 sessionid。 为可选参数。 若未指定,将返回用户的所有会话。
steamiduint64其会话将被枚举的用户。
include_all_user_messagesbool(可选)设置是否包含对所有用户的消息。 默认为 false。
include_auth_user_messagebool(可选)设置是否包含对验证过的用户的消息。 默认为 false。
languagestring(可选)文本要使用的本地化语言。

返回一个 Steam ID 所参与的会话的列表。

如果设置了可选用的 bool 参数,将返回各会话的更多详情。

注意: 此调用需要发行商 API 密钥以使用此方法。 因此,此 API 必须通过安全服务器调用,且绝不能由客户端直接调用!

响应示例:
{ "response": { [ { "sessionid": "123", "appid": "100", "title": { "token": "#TitleToken", "variables": [ { "key": "keyName", "value": "keyValue" } ] }, "time_created": "100000", // Unix 时间 "time_updated": "200000", //Unix 时间 "user_status": [ { "steamid": "76561197960265729", "state": "waiting", "title": { "token": "#TitleToken", "variables": [ { "key": "username", "value": "Bob" } { "key": "level", "value": "1" } ] }, "message": { "token": "#StatusMessageToken", "variables": [ { "key": "city", "value": "Bellevue" } ] } }, { "steamid": "76561197960265730", "state": "waiting", "title": { "token": "#TitleToken", "variables": [ { "key": "username", "value": "Greg" } { "key": "level", "value": "2" } ] }, "message": { "token": "#StatusMessageToken", "variables": [ { "key": "city", "value": "Seattle" } ] } } ] } }

调用示例:
{ "steamid": "76561197960265729", "include_all_user_messages": "0", "include_auth_user_message": "1" }

GetSessionDetailsForApp

GET https://partner.steam-api.com/IGameNotificationsService/GetSessionDetailsForApp/v1/
名称类型是否必需描述
keystringSteamworks Web API 发行商验证密钥。
sessions{message}要接收其详情的会话。
appiduint32会话的 appid。
languagestring文本要使用的本地化语言。

返回指定会话的详情。

注意: 此调用需要发行商 API 密钥以使用此方法。 因此,此 API 必须通过安全服务器调用,且绝不能由客户端直接调用!

响应示例:
{ "response": { [ { "sessionid": "12", "appid": "100", "title": { "token": "#TitleToken", "variables": [ { "key": "keyName", "value": "keyValue" } ] }, "time_created": "100000", // Unix 时间 "time_updated": "200000", //Unix 时间 "user_status": [ { "steamid": "76561197960265729", "state": "waiting", "title": { "token": "#TitleToken", "variables": [ { "key": "username", "value": "Bob" } { "key": "level", "value": "1" } ] }, "message": { "token": "#StatusMessageToken", "variables": [ { "key": "city", "value": "Bellevue" } ] } }, { "steamid": "76561197960265730", "state": "waiting", "title": { "token": "#TitleToken", "variables": [ { "key": "username", "value": "Greg" } { "key": "level", "value": "2" } ] }, "message": { "token": "#StatusMessageToken", "variables": [ { "key": "city", "value": "Seattle" } ] } } ] } }

调用示例:
{ "sessions": [ { "sessionid": "12", "include_all_user_messages": "0" }, { "sessionid": "13", "include_all_user_messages": "0" } ] }

RequestNotifications

POST https://partner.steam-api.com/IGameNotificationsService/RequestNotifications/v1/
名称类型是否必需描述
keystringSteamworks Web API 发行商验证密钥。
steamiduint64请求其通知的 Steam ID。
appiduint32请求其通知的 App ID。

请求让用户接收一个应用的游戏通知。

每当用户开始玩一个需要通知功能的游戏时,服务器必须为已登录的用户调用 RequestNotifications。 这将请求用户选择接收您特定游戏的通知,从而为您的游戏注册向该用户发送离线通知的功能。 每次启动游戏时,此 API 最多调用一次。 如果用户决定不接收通知,之后的调用便不会再次询问用户。

注意: 此调用需要发行商 API 密钥以使用此方法。 因此,此 API 必须通过安全服务器调用,且绝不能由客户端直接调用!

响应示例:
{ "response": { } }

调用示例:
{ "steamid": "76561197960265729", "appid": 480 }

DeleteSession

POST https://partner.steam-api.com/IGameNotificationsService/DeleteSession/v1/
名称类型是否必需描述
keystringSteamworks Web API 发行商验证密钥。
sessioniduint64要删除的 sessionid。
appiduint32要删除的会话的 App ID。
steamiduint64(可选)为其发起请求的 Steam ID。若指定,该用户必须在会话中,且加入会话的所有用户必须为该用户的好友。

删除进行中的异步游戏会话。 这将移除向此游戏会话中所有用户发送的全部通知。

注意: 此调用需要发行商 API 密钥以使用此方法。 因此,此 API 必须通过安全服务器调用,且绝不能由客户端直接调用!

响应示例:
{ "response": { } }

调用示例:
{ "sessionid": "10" }

DeleteSessionBatch

POST https://partner.steam-api.com/IGameNotificationsService/DeleteSessionBatch/v1/
名称类型是否必需描述
keystringSteamworks Web API 发行商验证密钥。
sessioniduint64要删除的 sessionid。
appiduint32要删除的会话的 App ID。

批量删除异步游戏会话。

注意: 此调用需要发行商 API 密钥以使用此方法。 因此,此 API 必须通过安全服务器调用,且绝不能由客户端直接调用!