public function getProfileXml()
 {
     if ($this->profile == null) {
         $url = self::BASE_URL . $this->steamId . '/?xml=1';
         $xml = Helper::cURL($url);
         $this->profile = new \SimpleXMLElement($xml);
     }
     return $this->profile;
 }
 public static function GetTimeDifference()
 {
     try {
         $response = Helper::cURL('http://api.steampowered.com/ITwoFactorService/QueryTime/v0001', null, ['steamid' => 0]);
         $json = json_decode($response, true);
         if (isset($json['response']) && isset($json['response']['server_time'])) {
             return (int) $json['response']['server_time'] - time();
         }
     } catch (\Exception $ex) {
     }
     return 0;
 }
示例#3
0
 public function send($token = '')
 {
     $url = 'https://steamcommunity.com/tradeoffer/new/send';
     $referer = 'https://steamcommunity.com/tradeoffer/new/?partner=' . $this->accountId;
     $params = ['sessionid' => $this->steamCommunity->getSessionId(), 'serverid' => '1', 'partner' => Helper::toCommunityID($this->accountId), 'tradeoffermessage' => $this->message, 'json_tradeoffer' => json_encode($this), 'trade_offer_create_params' => empty($token) ? "{}" : json_encode(['trade_offer_access_token' => $token])];
     $response = $this->steamCommunity->cURL($url, $referer, $params);
     $json = json_decode($response, true);
     if (is_null($json)) {
         return 0;
     } else {
         if (isset($json['tradeofferid'])) {
             return $json['tradeofferid'];
         } else {
             return 0;
         }
     }
 }
 /**
  * Accept a trade offer.
  * @param TradeOffer $tradeOffer
  * @return bool
  */
 public function acceptTrade(TradeOffer $tradeOffer)
 {
     if (!$tradeOffer->isOurOffer()) {
         $url = 'https://steamcommunity.com/tradeoffer/' . $tradeOffer->getTradeOfferId() . '/accept';
         $referer = 'https://steamcommunity.com/tradeoffer/' . $tradeOffer->getTradeOfferId() . '/';
         $params = ['sessionid' => $this->steamCommunity->getSessionId(), 'serverid' => '1', 'tradeofferid' => $tradeOffer->getTradeOfferId(), 'partner' => Helper::toCommunityID($tradeOffer->getOtherAccountId())];
         $response = $this->steamCommunity->cURL($url, $referer, $params);
         $json = json_decode($response, true);
         if (is_null($json)) {
             return false;
         } else {
             return isset($json['tradeid']);
         }
     }
     return false;
 }
 /**
  * @param int $page
  * @return HistoryItem[]
  */
 public function getHistory($page = 1)
 {
     $history = [];
     $xpath = $this->getHistoryXPath($page);
     /** @var \DOMElement[] $historyItems */
     $historyItems = $xpath->query('//div[contains(@class, "group_summary")]/div[contains(@class, "historyItem")]');
     foreach ($historyItems as $historyItem) {
         $type = $xpath->query('.//span[contains(@class, "historyShort")]', $historyItem)->item(0)->nodeValue;
         $date = $xpath->query('.//span[contains(@class, "historyDate")]', $historyItem)->item(0)->nodeValue;
         $users = $xpath->query('.//a', $historyItem);
         if ($users->length == 2) {
             /** @var \DOMElement $user */
             $user = $users->item(1);
             $userAccountId = $user->getAttribute('data-miniprofile');
             /** @var \DOMElement $targetUser */
             $targetUser = $users->item(0);
             $targetAccountId = $targetUser->getAttribute('data-miniprofile');
             $history[] = new HistoryItem($type, $date, Helper::toCommunityID($userAccountId), Helper::toCommunityID($targetAccountId));
         } else {
             if ($users->length == 1) {
                 $user = $users->item(0);
                 $userAccountId = $user->getAttribute('data-miniprofile');
                 $history[] = new HistoryItem($type, $date, Helper::toCommunityID($userAccountId));
             }
         }
     }
     return $history;
 }
示例#6
0
 public function getWalletBalance()
 {
     if ($this->steamCommunity->isLoggedIn()) {
         $url = 'http://steamcommunity.com/market/';
         $response = $this->steamCommunity->cURL($url);
         $pattern = '/<span id=\\"marketWalletBalanceAmount\\">(.*)<\\/span>/i';
         preg_match($pattern, $response, $matches);
         if (!isset($matches[1])) {
             throw new SteamException('Unexpected response from Steam.');
         }
         $balance = $matches[1];
         if (substr($balance, -1) == '.') {
             $balance = substr($balance, 0, -1);
         }
         return Helper::getAmount($balance);
     } else {
         return 0;
     }
 }