運行一個循環使用koraktor的Steam Condenser,您可以輕鬆地將這些信息並使用它。
require_once('steam/db.php');
$_STEAMAPI = "YOURAPIKEYHERE"; // You get this from http://steamcommunity.com/dev/apikey
$playersStr = ""; // This is a comma separated list of profile IDs
// if you don't have those, Steam Condenser has functions to acquire it
$players = array(); // For this example, I'm building an array of players assuming you'll have multiple players returned.
// You are free to skip this if you are only pulling one back
$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$playersStr";
$json_object= file_get_contents($url);
$json_decoded = json_decode($json_object);
foreach ($json_decoded->response->players as $player)
{
$players[$player->steamid]['personaname'] = $player->personaname; // In game name
$players[$player->steamid]['profileurl'] = $player->profileurl; // URL to their Steam Community Page
$players[$player->steamid]['avatar'] = $player->avatar; // Small Avatar Icon URL
$players[$player->steamid]['avatarmedium'] = $player->avatarmedium; // Thumbnail avatar URL
$players[$player->steamid]['avatarfull'] = $player->avatarfull; // Full sized Avatar URL
}
如果你沒有一個球員的個人資料的ID,但確實有蒸汽ID,就可以得到這樣的配置文件ID:
$profile_id = SteamId::convertSteamIdToCommunityId($steam_id);
$ html和$ profilepicture我從哪裏得到thoose值,就像我評論「Kirugan」我是一個大的noob當時.. :) –
$ html是頁面內容,他們抓住使用捲曲,'file_get_contents'或任何URL解析器... $ profile_picture是結果,它不應該是一個主動變量e,所以當你使用url時,只需使用echo $ profile_picture [1]; ..回答更新 – Osa
不要使用正則表達式來解析HTML。請參閱http://stackoverflow.com/q/3577641/1592648 –