php 通过用户昵称获取steamID

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19247887/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 19:05:55  来源:igfitidea点击:

Get steamID by user nickname

phpsteam-web-api

提问by Dmitriy Zhura

Is it possible to get user's steamID by his nickname? I didn't find solution in steam API documentation. The only one thing that I found is an old post on http://dev.dota2.com:

是否可以通过昵称获取用户的 SteamID?我在 Steam API 文档中没有找到解决方案。我发现的唯一一件事是http://dev.dota2.com上的一篇旧帖子:

You can use this to search the Dota2 API directly using the player_name option of GetMatchHistory You can then find their 32-bit ID in the list and then convert it to a 64-bit ID.

你可以使用GetMatchHistory 的player_name 选项直接使用它来搜索Dota2 API,然后可以在列表中找到他们的32 位ID,然后将其转换为64 位ID。

But now GetMatchHistoryfunction does not have player_nameparameter. Now it requires account_id.

但是现在GetMatchHistory函数没有player_name参数。现在它需要account_id.

So how the websites like http://dotabuff.com/search?q=Dendiget this info?

那么像http://dotabuff.com/search?q=Dendi这样的网站是如何获得这些信息的呢?

回答by barsanuphe

You can use

您可以使用

GET http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/

获取http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/

to get the SteamID from the custom URL of a Steam Profile. See http://wiki.teamfortress.com/wiki/WebAPI/ResolveVanityURL

从 Steam 个人资料的自定义 URL 获取 SteamID。见http://wiki.teamfortress.com/wiki/WebAPI/ResolveVanityURL

You can't get the steamID from someone's current nickname because nicknames can change and are not unique.

您无法从某人的当前昵称中获取 steamID,因为昵称可以更改并且不是唯一的。

回答by Andy

Using PHP and the Steam Condenserproject, you can accomplish this.

使用 PHP 和Steam Condenser项目,您可以完成此任务。

require_once('steam/steam-condenser.php');

$playername = 'NAMEOFPLAYER';
try
{
    $id = SteamId::create($playername);
} 
catch (SteamCondenserException $s)
{
    // Error occurred
}

echo $id->getSteamId;

There are usage examplesin the wiki for the project if you need more information.

用法示例在wiki的项目,如果您需要了解更多信息。

回答by Samuel Nicholson

Have you read over this from the Steam Web API?

你有没有从 Steam Web API 上读过这个?

https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29

https://developer.valvesoftware.com/wiki/Steam_Web_API#GetPlayerSummaries_.28v0002.29

It has an example of using a steam profile url to return the users Steam ID, also some other arguments to gather other information.

它有一个使用 Steam 配置文件 url 返回用户 Steam ID 的示例,还有一些其他参数来收集其他信息。

If you read down a bit from there it states that "Returns the friend list of any Steam user

如果您从那里向下阅读,它会指出“返回任何 Steam 用户的好友列表

Example URL: http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamid=76561197960435530&relationship=friend"

示例网址:http: //api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&steamid=76561197960435530&relationship=friend

  • you can add the arguments for profile information to be returned such as the Steam ID providing the profile is public.
  • 您可以添加要返回的个人资料信息的参数,例如提供个人资料公开的 Steam ID。