Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class SteamFriendFinder
- {
- private $players = array();
- private $handle = null;
- private $apiKey = "XXXXXXXXXXX";
- public function __construct()
- {
- $this->handle = fopen("steam.txt","a+");
- }
- public function getFriends($id,$level = 0)
- {
- $f = @file_get_contents("http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=".$this->apiKey."&steamid=".$id."&relationship=friend");
- if ($f){
- $arr = json_decode($f);
- foreach($arr->friendslist->friends as $friend)
- {
- $str = null;
- for ($i=0;$i<$level;$i++)
- {
- $str .= '.';
- }
- if (!isset($this->players[(string)$friend->steamid]))
- {
- $str .= $this->getUsernameById((string)$friend->steamid);
- echo $str."\n";
- fwrite($this->handle,$str."\r\n");
- $this->players[(string)$friend->steamid] = $friend;
- $this->getFriends((string)$friend->steamid,$level+1);
- }
- }
- }
- }
- public function getUsernameById($id)
- {
- $f = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$this->apiKey."&steamids=".$id);
- $arr = json_decode($f);
- return $arr->response->players[0]->personaname;
- }
- }
- $sff = new SteamFriendFinder();
- $sff->getFriends("76561198027123396");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement