invisnik/laravel-steam-auth

Unable to login over XML request

Closed this issue · 2 comments

I just tried to login using this API, which was working fine a couple days ago. I noticed there was an update and tried to update locally. Then I got an error saying:

Trying to get property of non-object

public function userInfo()
{
    switch (Config::get('steam-login.method')) {
        case 'xml':
            $data = simplexml_load_string(self::curl(sprintf(str_replace('https://', 'http://', self::STEAM_PROFILE).'/?xml=1', $this->player->steamid)), 'SimpleXMLElement', LIBXML_NOCDATA);
            $this->player->name = (string) $data->steamID;
            $this->player->realName = (string) $data->realname;
            $this->player->playerState = ucfirst((string) $data->onlineState);
            $this->player->stateMessage = (string) $data->stateMessage;
            $this->player->privacyState = ucfirst((string) $data->privacyState);
            $this->player->visibilityState = (int) $data->visibilityState;
            $this->player->avatarSmall = (string) $data->avatarIcon;
            $this->player->avatarMedium = (string) $data->avatarMedium;
            $this->player->avatarLarge = (string) $data->avatarFull;
            $this->player->profileURL = !empty((string) $data->customURL) ? sprintf(self::STEAM_PROFILE_ID, (string) $data->customURL) : sprintf(self::STEAM_PROFILE, $this->player->steamid);
            $this->player->joined = !empty($data->joined) ? $data->joined : null;
            break;
        case 'api':
            if (empty(Config::get('steam-login.api_key'))) {
                throw new RuntimeException('Steam API key not specified, please add it to your .env');
            }
            $data = json_decode(self::curl(sprintf(self::STEAM_API, Config::get('steam-login.api_key'), $this->player->steamid)));
            $data = $data->response->players[0];
            switch ($data->personastate) {
                case 0:
                    $data->personastate = 'Offline';

The error was noted for

$this->player->name = (string) $data->steamID;

on line 213.

When I changed the config to use the API I was able to get passed this and the login worked again.
A little side-node is that in your readme you direct uses to the config file as: steam-auth.php but it's called steam-login.php. Just a little side-note.

You're posting on the wrong steam auth lib.

Whoops you're right sorry about that.