1

The script run good, but only when I fetching out the groups of the user, it's says:

SteamUser.php (132): Creating default object from empty value

    function getProfileData() {

    //Set Base URL for the query:
    if(empty($this->vanityURL)) {
        $base = "http://steamcommunity.com/profiles/{$this->userID}/?xml=1";
    } else {
        $base = "http://steamcommunity.com/id/{$this->vanityURL}/?xml=1";
    }

    try {
        $content = SteamUtility::fetchURL($base);
        if ($content) {
            $parsedData = new SimpleXMLElement($content);
        } else {
            return null;
        }
    } catch (Exception $e) {
        //echo "Whoops! Something went wrong!\n\nException Info:\n" . $e . "\n\n";
        return null;
    }

    if(!empty($parsedData)) {   
        $this->steamID64 = (string)$parsedData->steamID64;
        $this->steamID = (string)$parsedData->steamID;
        $this->stateMessage = (string)$parsedData->stateMessage;
        $this->visibilityState = (int)$parsedData->visibilityState;
        $this->privacyState = (string)$parsedData->privacyState;

        $this->avatarIcon = (string)$parsedData->avatarIcon;
        $this->avatarMedium = (string)$parsedData->avatarMedium;
        $this->avatarFull = (string)$parsedData->avatarFull;

        $this->vacBanned = (int)$parsedData->vacBanned;
        $this->tradeBanState = (string)$parsedData->tradeBanState;
        $this->isLimitedAccount = (string)$parsedData->isLimitedAccount;

        $this->onlineState = (string)$parsedData->onlineState;
        $this->inGameServerIP = (string)$parsedData->inGameServerIP;

        //If their account is public, get that info:
        if($this->privacyState == "public") {
            $this->customURL = (string)$parsedData->customURL;
            $this->memberSince = (string)$parsedData->memberSince;

            $this->steamRating = (float)$parsedData->steamRating;
            $this->hoursPlayed2Wk = (float)$parsedData->hoursPlayed2Wk;

            $this->headline = (string)$parsedData->headline;
            $this->location = (string)$parsedData->location;
            $this->realname = (string)$parsedData->realname;
            $this->summary = (string)$parsedData->summary;
        }

        //If they're in a game, grab that info:
        if($this->onlineState == "in-game") {
            $this->inGameInfo = array();
            $this->inGameInfo["gameName"] = (string)$parsedData->inGameInfo->gameName;
            $this->inGameInfo["gameLink"] = (string)$parsedData->inGameInfo->gameLink;
            $this->inGameInfo["gameIcon"] = (string)$parsedData->inGameInfo->gameIcon;
            $this->inGameInfo["gameLogo"] = (string)$parsedData->inGameInfo->gameLogo;
            $this->inGameInfo["gameLogoSmall"] = (string)$parsedData->inGameInfo->gameLogoSmall;
        } 

        //Any weblinks listed in their profile:
        if(!empty($parsedData->weblinks)) {
            $this->weblinks = array();

            $i = 0;
            foreach ($parsedData->weblinks->weblink as $weblink) {
                $this->weblinks[$i]->title = (string)$weblink->title;
                $this->weblinks[$i]->link = (string)$weblink->link;
                $i++;
            }
        }   

  if(!empty($parsedData->groups)) {
            $this->groups = array();

            $i = 0;
            foreach ($parsedData->groups->group as $group) {

$this->groups[$i]->groupID64 = (string)$group->groupID64; // row 132 in script

                $this->groups[$i]->groupName = (string)$group->groupName;
                $this->groups[$i]->groupURL = (string)$group->groupURL;
                $this->groups[$i]->headline = (string)$group->headline;
                $this->groups[$i]->summary = (string)$group->summary;

                $this->groups[$i]->avatarIcon = (string)$group->avatarIcon;
                $this->groups[$i]->avatarMedium = (string)$group->avatarMedium;
                $this->groups[$i]->avatarFull = (string)$group->avatarFull;

                $this->groups[$i]->memberCount = (string)$group->memberCount;
                $this->groups[$i]->membersInChat = (string)$group->membersInChat;
                $this->groups[$i]->membersInGame = (string)$group->membersInGame;
                $this->groups[$i]->membersOnline = (string)$group->membersOnline; 

                $i++;
            }

        }                    

    }
}
  .

. . I already tried to using associative arrays, but didn't work; maybe with doing it all new. -_-

So, I can't set error_reporting(0) or ini_set at all.

I also used new stdClass() as a try. But I didn't get this running too.

4
  • set error_reporting(0) is not solving any problem. It hides the problem. But the problem is still lurking there unsolved. You should never need to do that (actually you should rather try the opposite and enable as many warnings reported as possible) Commented Aug 6, 2015 at 20:48
  • possible duplicate of Creating default object from empty value in PHP? Commented Aug 6, 2015 at 20:49
  • I writed an answer. Did it help? Would you like more help? Could you fix the issue? Commented Aug 10, 2015 at 8:54
  • I'm sorry! Yeah it worked well! Thank you very much! :) Commented Aug 14, 2015 at 18:16

1 Answer 1

1

You create an array.

$this->groups = array();

But in this array you donot create any object. You just use this array's elements (thoes are not initialized) as objects. You should add this line before your 132. row.

$this->groups[$i] = new Group();

Or something similar. If you do not have Group class you should try

$this->groups[$i] = new stdClass();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.