Ejemplo n.º 1
0
 /**
  * Updates the contents of the backpack using Steam Web API
  */
 public function fetch()
 {
     $params = ['SteamID' => $this->steamId64];
     $result = WebApi::getJSONData("IEconItems_{$this->getAppId()}", 'GetPlayerItems', 1, $params);
     $this->items = [];
     $this->preliminaryItems = [];
     foreach ($result->items as $itemData) {
         if ($itemData != null) {
             $inventoryClass = new \ReflectionClass(get_class($this));
             $namespace = $inventoryClass->getNamespaceName();
             $itemClass = $namespace . '\\' . $inventoryClass->getConstant('ITEM_CLASS');
             $item = new $itemClass($this, $itemData);
             if ($item->isPreliminary()) {
                 $this->preliminaryItems[] = $item;
             } else {
                 $this->items[$item->getBackpackPosition() - 1] = $item;
             }
         }
     }
     $this->fetchDate = time();
 }
 /**
  * Updates the contents of the backpack using Steam Web API
  */
 protected function internalFetch()
 {
     $params = ['SteamID' => $this->steamId64];
     $result = WebApi::getJSONData("IEconItems_{$this->getAppId()}", 'GetPlayerItems', 1, $params);
     $this->items = [];
     $this->preliminaryItems = [];
     foreach ($result->items as $itemData) {
         if ($itemData != null) {
             $inventoryClass = get_called_class();
             $itemClass = $inventoryClass::ITEM_CLASS;
             $item = new $itemClass($this, $itemData);
             if ($item->isPreliminary()) {
                 $this->preliminaryItems[] = $item;
             } else {
                 $this->items[$item->getBackpackPosition() - 1] = $item;
             }
         }
     }
 }