Search code examples
phpapiechosteamavatar

Echoing Steam avatar using the Steam API


Made a question earlier but it was a bit too vague, I have these pages of code:

steamauth.php: http://pastebin.com/j7Y3h56i

userInfo.php: http://pastebin.com/yuv2b8zT

I have a very basic knowledge of PHP, but an advanced knowledge of HTML. What I am looking to do is when a user logs into the site through the steam API, I would like print/echo the steam avatar of the user. I tried using

 <img src=<?php echo '"{$avatar}"'; ?> /> 

in the index.php as well as other variations, but nothing seems to work. What line of code can I use to echo the steam avatar, and where does it go?


Solution

  • use:

    <img src=<?php echo('"' . $avatar . '"'); ?></img>
    

    And make sure that your URL starts with http://
    to check just use:

    <php echo($avatar); ?>
    

    you always could use:

    <img src=<?php echo('"http://' . $avatar . '"'); ?></img>
    

    And NEVER forget:
    first load your functions/variables before they are usable :p