0

I'm trying to get the URL off a page from Steam. I'm using it to get the URL of the picture of any user who visits it. Here's the code that steam gives to me when I ask for the user's information:

{
"response": {
    "players": [
        {
            "steamid": "76561xxxxxxxxx",
            "communityvisibilitystate": 3,
            "profilestate": 1,
            "personaname": "xxxxx",
            "lastlogoff": 1402722290,
            "profileurl": "http://steamcommunity.com/id/xxxxxxxxxx/",
            "avatar": "http://media.steampowered.com/steamcommunity/public/images/avatars/f1/f1dd6xxxxxxxxxx883caxxxxxe6abaxxxxxxx32d4.jpg",
            "avatarmedium": "http://media.steampowered.com/steamcommunity/public/images/avatars/f1/fxxxxxxxxxxx83caf82xxxfexxxxxxxxxxaf1732d4_medium.jpg",
            "avatarfull": "http://media.steampowered.com/steamcommunity/public/images/avatars/f1/f1dxxxxxxxx88883caf82xxxxfccfexxxxxxxxx732d4_full.jpg",
            "personastate": 0,
            "realname": "xxxxx Walker",
            "primaryclanid": "103582xx142952xxxx",
            "timecreated": 1063407589,
            "personastateflags": 0,
            "loccountrycode": "US",
            "locstatecode": "WA",
            "loccityid": 3961
        }
    ]

}

What I'm trying to get is the url of "avatar":, but I am somewhat new to this.

After getting the URL, I wish to put it on a <div> with some other information, like the name, and such. Help is really appreciated right now!

1 Answers1

0

Assuming you're using javascript:

var s = GetSteamInfo(); //s is the string which represents the string
var o = JSON.parse(s);
var player = o["response"]["players"][0];

//now, to get the data
var avatar = player["avatar"];
var steamid = player["steamid"];
//etc..
kevin
  • 2,196
  • 1
  • 20
  • 24
  • It looks like it worked, but what I am doing is I have a weebly website, it does not support php, so I'm hosting the PHP somewhere else. And I did an ` – user1736490 Jun 16 '14 at 23:05
  • UPDATE: Yup. My web hosting service needs to support PHP for this to work. – user1736490 Dec 30 '14 at 20:28