Steam 接入工具類

之前有項目接入steam平臺,這兒整理了常用到的WebApi封裝缤至,可以參考

usage

     $steam = new SteamUtils([
     'appid' => $this->currentConfig['appid'],
     'appkey' => $this->currentConfig['appkey'],
     'steamid' => $this->steamid,
     'ticket' => $this->params['encrypted_loginkey'] ? :Cache::redis_get('_STEAM_LOGIN_'.$this->steamid),
     ]);
     $ret = $steam->ISteamUserAuth->AuthenticateUserTicket();
     if ( 0!==strcasecmp($ret['response']['params']['result'], 'OK') ){
         // TODO u business
     }
/**
 * SteamUtils
 * present by YCZ
 * Author: Nomandia
 * Date: 2020/6/19 13:53
 * @see https://partner.steamgames.com/doc/features/microtransactions/implementation#error_codes 錯誤代碼
 *
 * @property SteamUtils_IBroadcastService IBroadcastService
 * @property SteamUtils_IGameInventory IGameInventory
 * @property SteamUtils_ISteam ISteam
 * @property SteamUtils_ISteamApps ISteamApps
 * @property SteamUtils_ISteamCommunity ISteamCommunity
 * @property SteamUtils_ISteamEconomy ISteamEconomy
 * @property SteamUtils_ISteamGameServerStats ISteamGameServerStats
 * @property SteamUtils_ISteamMicroTxn ISteamMicroTxn
 * @property SteamUtils_ISteamNews ISteamNews
 * @property SteamUtils_ISteamUser ISteamUser
 * @property SteamUtils_ISteamUserAuth ISteamUserAuth
 * @property SteamUtils_ISteamUserStats ISteamUserStats
 * @property SteamUtils_ISteamWebAPIUtil ISteamWebAPIUtil
 *
 * @usage
 *     $steam = new SteamUtils([
 *        'appid' => $this->currentConfig['appid'],
 *        'appkey' => $this->currentConfig['appkey'],
 *        'steamid' => $this->steamid,
 *        'ticket' => $this->params['encrypted_loginkey'] ? :Cache::redis_get('_STEAM_LOGIN_'.$this->steamid),
 *     ]);
 *     $ret = $steam->ISteamUserAuth->AuthenticateUserTicket();
 *     if ( 0!==strcasecmp($ret['response']['params']['result'], 'OK') ){
 *         // TODO u business
 *     }
 */
class SteamUtils
{
    /**
     * @var string appid
     */
    public $appid;

    /**
     * @var string appkey
     */
    public $appkey;

    /**
     * @var string ticket
     */
    public $ticket;

    /**
     * @var string gameid
     */
    public $gameid;

    /**
     * @var string steamid
     */
    public $steamid;

    /**
     * @var bool use_ssl 開啟SSL(https)
     */
    public $use_ssl = false;

    /**
     * @var bool return_json 返回JSON數據潮罪,否則返回文本
     */
    public $return_json = true;

    /**
     * @var string language 語言代碼
     * @see https://baike.baidu.com/item/ISO%20639-1/8292914?fr=aladdin
     */
    public $language = 'zh';

    /**
     * @var string currency Steam支持的幣種(默認軟妹幣,單位分即100的整數倍)
     * @see https://partner.steamgames.com/doc/store/pricing/currencies
     */
    public $currency = 'CNY';

    /**
     * @var bool sandbox 是否開啟沙箱(MicroTxn用到领斥,僅改變URL)
     */
    public $sandbox = false;

    /**
     * Author: Great Nomandia
     * Created At 2020/6/19 14:36
     */
    function __construct()
    {
        if (is_array($func = func_get_arg(0))) {
            $this->appid = $func['appid'];
            $this->appkey = $func['appkey'];
            $this->steamid = $func['steamid'];
            $this->ticket = $func['ticket'];
        } else if (func_num_args() > 3) {
            $this->appid = func_get_arg(0);
            $this->appkey = func_get_arg(1);
            $this->steamid = func_get_arg(2);
            $this->ticket = func_get_arg(3);
        }
    }

    function __destruct()
    {
        static::$implements = null;
        $this->appid = $this->appkey = $this->steamid = $this->ticket = null;
    }

    /*********** ALIAS *************/

    protected static $implements = [];

    /**
     * @param string $name
     * @return mixed
     * @throws SteamException
     * Author: Great Nomandia
     * Created At 2020/6/19 15:16
     */
    function __get($name)
    {
        if (in_array($name, static::$implements)) {
            return static::$implements[$name];
        }
        $clazz = 'SteamUtils_' . $name; // 增加一個前綴
        if (class_exists($clazz) || !($clazz instanceof SteamUtils_ISteam)) {
            /** @var SteamUtils_ISteam $implements */
            static::$implements[$name] = new $clazz();
            return static::$implements[$name]->bind($this);
        }
        throw new SteamException('Interface[' . $name . '] not exists', 502);
    }

    /*********** CURL TOOLS *************/

    /**
     * @param string $url
     * @param mixed $params
     * @param bool $json
     * @param string $cookie
     * @param bool $use_ssl
     * @return string
     * Author: Great Nomandia
     * Created At 2020/6/19 14:06
     */
    static function get($url, $params = null, $json = true, $cookie = '', $use_ssl = false)
    {
        return $json ?
            static::requestJson($url, $params, 'GET', $cookie, $use_ssl) :
            static::request($url, $params, 'GET', $cookie, $use_ssl);
    }

    /**
     * @param string $url
     * @param mixed $params
     * @param bool $json
     * @param string $cookie
     * @param bool $use_ssl
     * @return string
     * Author: Great Nomandia
     * Created At 2020/6/19 14:06
     */
    static function post($url, $params = null, $json = true, $cookie = '', $use_ssl = false)
    {
        return $json ?
            static::requestJson($url, $params, 'POST', $cookie, $use_ssl) :
            static::request($url, $params, 'POST', $cookie, $use_ssl);
    }

    /**
     * @var int _curl_port 默認請求端口
     */
    static $_curl_port = 0;

    /**
     * @var array _curl_headers 附加的Header數據
     */
    static $_curl_headers = [];

    /**
     * @var int _curl_connect_timeout  連接超時時間
     */
    static $_curl_connect_timeout = 2;

    /**
     * @var int _curl_timeout 執(zhí)行超時時間
     */
    static $_curl_timeout = 5;

    /**
     * @var mixed fetch_result
     */
    static $fetch_result;

    /**
     * @var mixed fetch_error
     */
    static $fetch_error;

    /**
     * @param string $url
     * @param mixed $params
     * @param string $method
     * @param string $cookie
     * @param bool $use_ssl
     * @return mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 14:47
     */
    static function requestJson($url, $params = null, $method = 'GET', $cookie = '', $use_ssl = false)
    {
        $ret = static::request($url, $params, $method, $cookie, $use_ssl);
        return json_decode($ret, 1);
    }

    /**
     * @param string $url
     * @param mixed $params
     * @param string $method
     * @param string $cookie
     * @param bool $use_ssl
     * @return string
     * Author: Great Nomandia
     * Created At 2020/6/19 14:06
     */
    static function request($url, $params = null, $method = 'GET', $cookie = '', $use_ssl = false)
    {
        $ch = curl_init();
        if ('GET' == strtoupper($method)) {
            $param_str = '';
//            默認范文為ipv4
            curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);

            if (is_array($params)) {
                $param_str = http_build_query($params);
            } else if (is_string($params) && strlen($params) > 0) {
                $param_str = $params;
            }
            $url .= $param_str ? '?' . trim($param_str) : '';
            curl_setopt($ch, CURLOPT_URL, $url);
        } else {
            curl_setopt_array($ch, array(
                CURLOPT_URL => $url,
                CURLOPT_POST => 1,
                CURLOPT_POSTFIELDS => $params,
            ));
        }

        curl_setopt_array($ch, array(
            CURLOPT_HEADER => false,
            CURLOPT_RETURNTRANSFER => true, // 成功時返回取到的結果(如HTML或json)
            CURLOPT_CONNECTTIMEOUT => self::$_curl_connect_timeout,
            CURLOPT_TIMEOUT => self::$_curl_timeout,
            CURLOPT_HTTPHEADER => array(
                'Expect:',
            ),
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_SSL_VERIFYHOST => false,
        ));

        if (!empty(self::$_curl_headers)) {
            curl_setopt_array($ch, array(
                CURLOPT_HTTPHEADER => self::$_curl_headers,
            ));
        }

        // disable 100-continue
        if (!empty($cookie)) {
            if (is_array($cookie)) {
                $cs = [];
                foreach ($cookie as $k => $v) {
                    $cs[] = $k . '=' . $v;
                }
                $cookie = join('; ', $cs);
            }
            curl_setopt($ch, CURLOPT_COOKIE, $cookie);
        }
        // 關閉SSL設置漏麦,通常這樣就可以直接訪問HTTPS地址了
        if (!$use_ssl) {
            curl_setopt_array($ch, array(
                CURLOPT_SSL_VERIFYPEER => false,
                CURLOPT_SSL_VERIFYHOST => false,
            ));
        }
        if (self::$_curl_port) {
            curl_setopt($ch, CURLOPT_PORT, intval(self::$_curl_port));
        }
        self::$fetch_result = curl_exec($ch);
        self::$fetch_error = curl_error($ch);
        curl_close($ch);

        // 需要恢復的配置
        self::$_curl_port = 0;

        return self::$fetch_result ?: self::$fetch_error;
    }
}

/*********** EXCEPTION *************/
class SteamException extends Exception
{
}

/*********** SUPPORT INTERFACE *************/
abstract class SteamUtils_ISteam
{
    /**
     * @var SteamUtils steam
     */
    protected static $steam;

    function bind(&$steam)
    {
        static::$steam = $steam;
        return $this;
    }

    /**
     * @param string $url
     * @param array $params
     * @param bool $no_merge 不增加默認參數表
     * @return string|array|mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 15:42
     */
    function post($url, $params = [], $no_merge = false)
    {
        return (static::$steam)::post($url, $no_merge ? $params : array_merge([
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'steamid' => static::$steam->steamid,
        ], array_filter($params)), static::$steam->return_json);
    }

    /**
     * @param string $url
     * @param array $params
     * @param bool $no_merge
     * @return string|array|mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 17:11
     */
    function get($url, $params = [], $no_merge = false)
    {
        return (static::$steam)::get($url, $no_merge ? $params : array_merge([
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'steamid' => static::$steam->steamid,
        ], array_filter($params)), static::$steam->return_json);
    }

    /**
     * @param string $time
     * @return false|string
     * Author: Great Nomandia
     * Created At 2020/6/19 15:49
     */
    static function rfc3339($time)
    {
        return date('Y-m-d\TH:i:s\Z', strtotime($time));
    }
}

/*********** SUPPORT IMPLEMENTS *************/

/**
 * YCZ - Class IBroadcastService - 提供對 Steam 直播的訪問
 * @see https://partner.steamgames.com/doc/webapi/IBroadcastService
 * Author: Great Nomandia
 * Created At 2020/6/19 14:42
 */
class SteamUtils_IBroadcastService extends SteamUtils_ISteam
{
    /**
     * @var string
     */
    CONST URL_BROADCAST_SERVER = 'https://partner.steam-api.com/IBroadcastService/PostGameDataFrame/v1/';

    /**
     * @param mixed $broadcast_id
     * @param mixed $data
     * Author: Great Nomandia
     * Created At 2020/6/19 14:43
     * @return string|array|mixed
     */
    function PostGameDataFrame($broadcast_id, $data)
    {
        return $this->post(static::URL_BROADCAST_SERVER, [
            'broadcast_id' => $broadcast_id,
            'frame_data' => $data
        ]);
    }
}

/**
 * YCZ - Class SteamUtils_IGameInventory 這是與 Steam 經濟體交互的主接口
 * @see https://partner.steamgames.com/doc/webapi/IGameInventory
 * Author: Great Nomandia
 * Created At 2020/6/22 10:13
 */
class SteamUtils_IGameInventory extends SteamUtils_ISteam
{
    CONST URL_GAME_INVENTORY_GET_HISTORY_COMMAND_DETAILS = 'https://partner.steam-api.com/IGameInventory/GetHistoryCommandDetails/v1/';

    /**
     * @param string $command 在該資產上運行的命令
     * @param int $contextid 要獲取歷史記錄的上下文
     * @param string $arguments 一開始與命令一起提供的參數
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/IGameInventory#GetHistoryCommandDetails
     * Author: Great Nomandia
     * Created At 2020/6/22 10:13
     */
    function GetHistoryCommandDetails($command, $contextid, $arguments)
    {
        return $this->get(self::URL_GAME_INVENTORY_GET_HISTORY_COMMAND_DETAILS, [
            'command' => $command,
            'contextid' => $contextid,
            'arguments' => $arguments,
        ]);
    }

    CONST URL_GAME_INVENTORY_GET_USER_HISTORY = 'https://partner.steam-api.com/IGameInventory/GetUserHistory/v1/';

    /**
     * @param int $contextid 要獲取歷史記錄的上下文
     * @param int $starttime 要獲取的歷史記錄的開始時間
     * @param int $endtime 要獲取的歷史記錄的結束時間
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/IGameInventory#GetUserHistory
     * Author: Great Nomandia
     * Created At 2020/6/22 10:15
     */
    function GetUserHistory($contextid, $starttime = null, $endtime = null)
    {
        return $this->get(self::URL_GAME_INVENTORY_GET_USER_HISTORY, [
            'contextid' => $contextid,
            'starttime' => $starttime ?: mktime(0, 0, 0),
            'endtime' => $endtime ?: $_SERVER['REQUEST_TIME'],
        ]);
    }

    CONST URL_GAME_INVENTORY_HISTORY_EXECUTE_COMMANDS = 'https://partner.steam-api.com/IGameInventory/HistoryExecuteCommands/v1/';

    /**
     * @param int $contextid 要獲取歷史記錄的上下文
     * @param int $actorid 供客服人員執(zhí)行命令的唯一 32 位 ID
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/IGameInventory#HistoryExecuteCommands
     * Author: Great Nomandia
     * Created At 2020/6/22 10:17
     */
    function HistoryExecuteCommands($contextid, $actorid)
    {
        return $this->get(self::URL_GAME_INVENTORY_GET_HISTORY_COMMAND_DETAILS, [
            'contextid' => $contextid,
            'actorid' => $actorid,
        ]);
    }

    CONST URL_GAME_INVENTORY_SUPPORT_GET_ASSET_HISTORY = 'https://partner.steam-api.com/IGameInventory/SupportGetAssetHistory/v1/';

    /**
     * @param int $assetid 要操作的資產 ID
     * @param int $contextid 要獲取歷史記錄的上下文
     * @return array|mixed|string
     * @https://partner.steamgames.com/doc/webapi/IGameInventory#SupportGetAssetHistory
     * Author: Great Nomandia
     * Created At 2020/6/22 10:20
     */
    function SupportGetAssetHistory($assetid, $contextid)
    {
        return $this->get(self::URL_GAME_INVENTORY_SUPPORT_GET_ASSET_HISTORY, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'assetid' => $assetid,
            'contextid' => $contextid,
        ], true);
    }

    CONST URL_GAME_INVENTORY_UPDATE_ITEM_DEFS = 'https://partner.steam-api.com/IGameInventory/UpdateItemDefs/v0001';

    /**
     * @param string $itemdefs 待更新或創(chuàng)建的一個或多個物品定義兽赁,以 JSON 數組顯示
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/IGameInventory#UpdateItemDefs
     * Author: Great Nomandia
     * Created At 2020/6/22 10:21
     */
    function UpdateItemDefs($itemdefs)
    {
        /**
         * 請求值
         * curl --request POST \
         * --header "Content-Type: application/x-www-form-urlencoded" \
         * --form appid=30400 \
         * --form 'itemdefs=[{"appid":"30400","itemdefid":"418","type":"item","display_type":"bag","name":"Bag of Stuff","description":"This bag contains stuff.","background_color":"993300","tradable": true,"marketable": true,"commodity": true,"tags":"class:human;type:bag"}, {"appid": "30400","itemdefid":"403","type":"item","display_type":"cat","name":"Cat of Bags","description":"This cat contains multitudes."}]'
         * "https://api.steampowered.com/IGameInventory/UpdateItemDefs/v0001?key=xxxxxx"
         */
        /**
         * 返回值
         * {
         * "result": {
         * "updated": [
         * "418",
         * "403"
         * ],
         * "failed": [],
         * "success": true
         * }
         * }
         */
        return $this->get(self::URL_GAME_INVENTORY_UPDATE_ITEM_DEFS, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'itemdefs' => $itemdefs,
        ], true);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamApps - 用于訪問 Steam 上的應用程序的數據
 * Author: Great Nomandia
 * Created At 2020/6/19 18:16
 */
class SteamUtils_ISteamApps extends SteamUtils_ISteam
{
    CONST URL_GET_APP_BETAS = 'https://partner.steam-api.com/ISteamApps/GetAppBetas/v1/';

    /**
     * 為指定應用程序獲取所有測試版分支
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetAppBetas
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:18
     */
    function GetAppBetas()
    {
        return $this->get(static::URL_GET_APP_BETAS, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
        ]);
    }

    CONST URL_GET_APP_BUILDS = 'https://partner.steam-api.com/ISteamApps/GetAppBuilds/v1/';

    /**
     * 獲取應用程序的生成版本歷史。
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetAppBuilds
     * @param int $count 要獲取的生成版本數量疤祭,默認為 10目胡。
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:25
     */
    function GetAppBuilds($count = 10)
    {
        return $this->get(static::URL_GET_APP_BUILDS, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'count' => $count,
        ]);
    }

    CONST URL_GET_APP_DEPOT_VERSIONS = 'https://partner.steam-api.com/ISteamApps/GetAppDepotVersions/v1/';

    /**
     * 為指定應用程序獲取所有 depot 的所有版本
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetAppDepotVersions
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:26
     */
    function GetAppDepotVersions()
    {
        return $this->get(static::URL_GET_APP_DEPOT_VERSIONS);
    }

    CONST URL_GET_APP_LIST = 'https://api.steampowered.com/ISteamApps/GetAppList/v2/';

    /**
     * 獲取公開應用的完整列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetAppList
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:27
     */
    function GetAppList()
    {
        /**
         * applist
         * apps - 包含應用程序的列表逮光。
         * appid - uint32 - 此應用程序的 App ID盖呼。
         * name - string - 此應用程序的名稱
         */
        return $this->get(static::URL_GET_APP_DEPOT_VERSIONS, null, true);
    }

    CONST URL_GET_CHEATING_REPORTS = 'https://partner.steam-api.com/ISteamApps/GetCheatingReports/v1/';

    /**
     * 獲取就此應用提交的作弊舉報的列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetCheatingReports
     * @param int $timebegin 時間范圍開始
     * @param int $timeend 時間范圍結束
     * @param bool $includereports 包括不是封禁的舉報
     * @param bool $includebans 包括是封禁的舉報
     * @param null $reportidmin 最少的舉報 ID
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:30
     */
    function GetCheatingReports($timebegin, $timeend, $includereports = true, $includebans = true, $reportidmin = null)
    {
        return $this->get(static::URL_GET_CHEATING_REPORTS, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'timebegin' => $timebegin,
            'timeend' => $timeend,
            'includereports' => $includereports,
            'includebans' => $includebans,
            'reportidmin' => $reportidmin,
        ], true);
    }

    CONST URL_GET_PARTNER_APP_LIST_FOR_WEB_API_KEY = 'https://partner.steam-api.com/ISteamApps/GetPartnerAppListForWebAPIKey/v1/';

    /**
     * Get a list of appIDs associated with a WebAPI key. Type_filter can used to specify certain app types to be returned. Possible values are "game,application,tool,demo,dlc,music". When type_filter is blank or not used, all apps are returned.
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetPartnerAppListForWebAPIKey
     * @param string $type_filter Optional comma separated list of types to filter on
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:34
     */
    function GetPartnerAppListForWebAPIKey($type_filter)
    {
        /**
         * {"applist":{"apps":{"app":[{
         * "appid": 500,
         * "app_type": "game"
         * },
         * {
         * "appid": 222840,
         * "app_type": "tool"
         * },
         * {
         * "appid": 222860,
         * "app_type": "tool"
         * }    ]}}}
         */
        return $this->get(static::URL_GET_PARTNER_APP_LIST_FOR_WEB_API_KEY, [
            'key' => static::$steam->appkey,
            'type_filter' => $type_filter,
        ], true);
    }

    CONST URL_GET_PLAYERS_BANNED = 'https://partner.steam-api.com/ISteamApps/GetPlayersBanned/v1/';

    /**
     * 獲取本封禁的玩家id
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetPlayersBanned
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:36
     */
    function GetPlayersBanned()
    {
        return $this->get(static::URL_GET_PLAYERS_BANNED, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
        ]);
    }

    CONST URL_GET_SERVER_LIST = 'https://partner.steam-api.com/ISteamApps/GetServerList/v1/';

    /**
     * 獲取服務器列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetServerList
     * @param string $filter
     * @param int $limit
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:37
     */
    function GetServerList($filter, $limit = 100)
    {
        return $this->get(static::URL_GET_SERVER_LIST, [
            'key' => static::$steam->appkey,
            'filter' => $filter,
            'limit' => $limit
        ]);
    }

    CONST URL_GET_SERVERS_AT_ADDRESS = 'https://api.steampowered.com/ISteamApps/GetServersAtAddress/v1/';

    /**
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#GetServersAtAddress
     * @param $addr
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:39
     */
    function GetServersAtAddress($addr)
    {
        return $this->get(static::URL_GET_SERVERS_AT_ADDRESS, [
            'addr' => $addr,
        ], true);
    }

    CONST URL_SET_APP_BUILD_LIVE = 'https://partner.steam-api.com/ISteamApps/SetAppBuildLive/v1/';

    /**
     * 設置App版本
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#SetAppBuildLive
     * @param int $buildid
     * @param string $betakey
     * @param string $description
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:41
     */
    function SetAppBuildLive($buildid, $betakey, $description = null)
    {
        return $this->get(static::URL_SET_APP_BUILD_LIVE, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'buildid' => $buildid,
            'betakey' => $betakey,
            'description' => $description
        ], true);
    }

    CONST URL_UP_TO_DATE_CHECK = 'https://api.steampowered.com/ISteamApps/UpToDateCheck/v1/';

    /**
     * @see https://partner.steamgames.com/doc/webapi/ISteamApps#UpToDateCheck
     * @param int $version
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:43
     */
    function UpToDateCheck($version)
    {
        return $this->get(static::URL_SET_APP_BUILD_LIVE, [
            'appid' => static::$steam->appid,
            'version' => $version,
        ], true);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamCommunity - 提供對 Steam 社區(qū)功能的訪問限制
 * @see https://partner.steamgames.com/doc/webapi/ISteamCommunity
 * Author: Great Nomandia
 * Created At 2020/6/22 9:42
 */
class SteamUtils_ISteamCommunity extends SteamUtils_ISteam
{

    CONST URL_COMMUNITY_REPORT_ABUSE = 'https://partner.steam-api.com/ISteamCommunity/ReportAbuse/v1/';

    /**
     * 允許發(fā)行商報告在其社區(qū)中心中舉止不當的用戶
     * @param mixed $steamidActor
     * @param mixed $steamidTarget
     * @param int $abuseType
     * @param int $contentType
     * @param string $description
     * @param int $gid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/22 9:46
     */
    function ReportAbuse($steamidActor, $steamidTarget, $abuseType, $contentType, $description, $gid)
    {
        return $this->post(static::URL_COMMUNITY_REPORT_ABUSE, [
            'key' => static::$steam->appkey,
            'steamidActor' => $steamidActor,
            'steamidTarget' => $steamidTarget,
            'appid' => static::$steam->appid,
            'abuseType' => $abuseType,
            'contentType' => $contentType,
            'description' => $description,
            'gid' => $gid,
        ], true);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamEconomy - 與 Steam 經濟體交互的次級接口
 * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy
 * @see https://partner.steamgames.com/doc/features/inventory/economy
 * Author: Great Nomandia
 * Created At 2020/6/22 9:47
 */
class SteamUtils_ISteamEconomy extends SteamUtils_ISteam
{

    CONST URL_ECONOMY_CAN_TRADE = 'https://partner.steam-api.com/ISteamEconomy/CanTrade/v1/';

    /**
     * @param mixed $targetid 交易邀請的目標用戶的 steamID。
     * @param mixed $steamid 嘗試發(fā)起交易的用戶的 steamID惜辑。
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#CanTrade
     * Author: Great Nomandia
     * Created At 2020/6/22 9:50
     */
    function CanTrade($targetid, $steamid = null)
    {
        return $this->get(static::URL_ECONOMY_CAN_TRADE, [
            'targetid' => $targetid,
            'steamid' => $steamid ?: static::$steam->steamid,
        ]);
    }

    CONST URL_ECONOMY_FINALIZE_ASSET_TRANSACTION = 'https://partner.steam-api.com/ISteamEconomy/FinalizeAssetTransaction/v1/';

    /**
     * @param mixed $txnid 交易 ID
     * @param mixed $steamid 購買用戶的 SteamID
     * @param mixed $language 用戶的本地語言
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#FinalizeAssetTransaction
     * Author: Great Nomandia
     * Created At 2020/6/22 9:53
     */
    function FinalizeAssetTransaction($txnid, $steamid = null, $language = null)
    {
        return $this->post(self::URL_ECONOMY_FINALIZE_ASSET_TRANSACTION, [
            'txnid' => $txnid,
            'steamid' => $steamid ?: static::$steam->steamid,
            'language' => $language ?: static::$steam->language,
        ]);
    }

    CONST URL_ECONOMY_GET_ASSET_CLASS_INFO = 'https://api.steampowered.com/ISteamEconomy/GetAssetClassInfo/v1/';

    /**
     * @param int $class_count 請求的類數量。 必須至少為 1
     * @param int $classid0 nth 類的類 ID
     * @param string $language 用戶的本地語言
     * @param int $instanceid0 nth 類的實例 ID
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#GetAssetClassInfo
     * Author: Great Nomandia
     * Created At 2020/6/22 9:56
     */
    function GetAssetClassInfo($class_count, $classid0, $language = null, $instanceid0 = null)
    {
        return $this->get(self::URL_ECONOMY_GET_ASSET_CLASS_INFO, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'language' => $language ?: static::$steam->language,
            'class_count' => $class_count,
            'classid0' => $classid0,
            'instanceid0' => $instanceid0,
        ], true);
    }

    CONST URL_ECONOMY_GET_ASSET_PRICES = 'https://api.steampowered.com/ISteamEconomy/GetAssetPrices/v1/';

    /**
     * 返回用戶能夠購買的物品的價格與類型
     * @param string $currency 要篩選的貨幣
     * @param string $language 用戶的本地語言
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#GetAssetPrices
     * Author: Great Nomandia
     * Created At 2020/6/22 9:59
     */
    function GetAssetPrices($currency = null, $language = null)
    {
        return $this->get(self::URL_ECONOMY_GET_ASSET_PRICES, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'currency' => $currency ?: static::$steam->currency,
            'language' => $language ?: static::$steam->language,
        ]);
    }

    CONST URL_ECONOMY_GET_EXPORTED_ASSETS_FOR_USER = 'https://partner.steam-api.com/ISteamEconomy/GetExportedAssetsForUser/v1/';

    /**
     * 從另一個游戲獲取資產清單以導入
     * @param mixed $contextid 要導出物品的上下文
     * @param mixed $steamid 用戶的 SteamID
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#GetExportedAssetsForUser
     * Author: Great Nomandia
     * Created At 2020/6/22 10:01
     */
    function GetExportedAssetsForUser($contextid, $steamid = null)
    {
        return $this->get(static::URL_ECONOMY_GET_EXPORTED_ASSETS_FOR_USER, [
            'steamid' => $steamid ?: static::$steam->steamid,
            'contextid' => $contextid
        ]);
    }

    CONST URL_ECONOMY_GET_MARKET_PRICES = 'https://partner.steam-api.com/ISteamEconomy/GetMarketPrices/v1/';

    /**
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#GetMarketPrices
     * Author: Great Nomandia
     * Created At 2020/6/22 10:02
     */
    function GetMarketPrices()
    {
        return $this->get(self::URL_ECONOMY_GET_MARKET_PRICES, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
        ], true);
    }

    CONST URL_ECONOMY_START_ASSET_TRANSACTION = 'https://partner.steamgames.com/doc/webapi/ISteamEconomy#StartAssetTransaction';

    /**
     * @param mixed $assetid0 用戶購買的第一個資產的 ID疫赎。必須有至少一個 ID
     * @param int $assetquantity0 用戶購買的 assetid0 的數量
     * @param string $currency 用戶的本地貨幣
     * @param string $language 用戶的本地語言
     * @param string $ipaddress 用戶的 IP 地址
     * @param string $referrer 引用 URL
     * @param bool $clientauth 若為 true(默認為 false)韵丑,授權將顯示在用戶的 Steam 客戶端界面上,而非以網頁形式顯示虚缎,因此對那些有產品嵌入的商店有用
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#StartAssetTransaction
     * Author: Great Nomandia
     * Created At 2020/6/22 10:07
     */
    function StartAssetTransaction($assetid0, $assetquantity0, $currency = null, $language = null, $ipaddress = null, $referrer = null, $clientauth = false)
    {
        return $this->post(self::URL_ECONOMY_START_ASSET_TRANSACTION, [
            'assetid0' => $assetid0,
            'assetquantity0' => $assetquantity0,
            'currency' => $currency ?: static::$steam->currency,
            'language' => $language ?: static::$steam->language,
            'ipaddress' => $ipaddress ?: Utils::ip(),
            'referrer' => $referrer ?: $_SERVER['HTTP_REFERER'],
            'clientauth' => $clientauth,
        ]);
    }

    CONST URL_ECONOMY_START_TRADE = 'https://partner.steam-api.com/ISteamEconomy/StartTrade/v1/';

    /**
     * @param string $partya
     * @param string $partyb
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamEconomy#StartTrade
     * Author: Great Nomandia
     * Created At 2020/6/22 10:09
     */
    function StartTrade($partya, $partyb)
    {
        return $this->get(self::URL_ECONOMY_START_TRADE, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'partya' => $partya,
            'partyb' => $partyb
        ]);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamGameServerStats 獲取游戲服務器統(tǒng)計數據并與之交互的接口
 * @see https://partner.steamgames.com/doc/webapi/ISteamGameServerStats
 * Author: Great Nomandia
 * Created At 2020/6/22 10:24
 */
class SteamUtils_ISteamGameServerStats extends SteamUtils_ISteam
{
    CONST URL_GAME_SERVER_STATS_GET_GAME_SERVER_PLAYER_STATS_FOR_GAME = 'https://partner.steam-api.com/ISteamGameServerStats/GetGameServerPlayerStatsForGame/v1/';

    /**
     * @param int $gameid 要獲取統(tǒng)計的 game ID;若非模組钓株,可在此安全使用 AppID
     * @param string $rangestart 范圍的起始日期/時間(格式:YYYY-MM-DD HH:MM:SS 西雅圖本地時間)
     * @param string $rangeend 范圍的結束日期/時間(格式:YYYY-MM-DD HH:MM:SS 西雅圖本地時間)
     * @param int $maxresult 返回的結果的最大數量(不超過 1000)
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/22 10:27
     */
    function GetGameServerPlayerStatsForGame($gameid, $rangestart = null, $rangeend = null, $maxresult = 1000)
    {
        return $this->get(static::URL_GAME_SERVER_STATS_GET_GAME_SERVER_PLAYER_STATS_FOR_GAME, [
            'key' => static::$steam->appkey,
            'gameid' => $gameid ?: static::$steam->appid,
            'appid' => static::$steam->appid,
            'rangestart' => $rangestart ?: date('Y-m-d 00:00:00'),
            'rangeend' => $rangeend ?: date('Y-m-d 23:59:59'),
        ]);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamMicroTxn - 這是用于支持小額交易(游戲內購)的接口
 * 注意: 此調用需要發(fā)行商 API 密鑰以使用此方法实牡。 因此,此 API 必須通過安全服務器調用轴合,且絕不能由客戶端直接調用创坞!
 * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn
 * Author: Great Nomandia
 * Created At 2020/6/19 15:21
 */
class SteamUtils_ISteamMicroTxn extends SteamUtils_ISteam
{

    CONST URL_MICRO_TXN_ADJUST_AGREEMENT = 'https://partner.steam-api.com/ISteamMicroTxn/AdjustAgreement/v1/';

    /**
     * 解析URL自動調整Sandbox的請求接口
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxnSandbox
     * @param string $url
     * @return string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:13
     */
    static function parseUrl($url)
    {
        return static::$steam->sandbox ?
            strtr($url, ['ISteamMicroTxn' => 'ISteamMicroTxnSandbox']) : $url;
    }

    /**
     * 向扣款類型為“Steam”的協(xié)議的結算時間表添加時間
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#AdjustAgreement
     * @param mixed $agreementid Steam 扣款協(xié)議的唯一 ID
     * @param string $nextprocessdate 下個循環(huán)訂閱扣款應開始的日期, 格式為 YYYYMMDD受葛。
     * 日期只能向之后調整题涨,表示您希望為訂閱添加時間。 如果日期超出訂閱的結束時間总滩,結束時間將延長纲堵。
     * @return string|array|mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 15:32
     */
    function AdjustAgreement($agreementid, $nextprocessdate)
    {
        /**
         * 返回值
         * response
         *     result - 操作結果。 (OK 或 Failure)
         *     params
         *         agreementid - 唯一的 64 位 Steam 扣款協(xié)議 ID闰渔。
         *         nextprocessdate - 下個循環(huán)訂閱扣款開始的日期席函, 格式為 YYYYMMDD。
         *     error - 可選冈涧。僅在結果為 Failure 時返回茂附。
         *         errorcode - 錯誤或事件代碼。 參見:附錄 B :錯誤代碼
         *         errordesc - 錯誤或事件的消息督弓。
         *
         * @TODO 下文省略了 result 和 error 項目营曼,因為所有接口都會返回
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_ADJUST_AGREEMENT), [
            'agreementid' => $agreementid,
            'nextprocessdate' => $nextprocessdate
        ]);
    }

    CONST URL_MICRO_TXN_CANCEL_AGREEMENT = 'https://partner.steam-api.com/ISteamMicroTxn/CancelAgreement/v1/';

    /**
     * 取消循環(huán)扣款協(xié)議(訂閱)
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#CancelAgreement
     * @param string $agreementid 唯一的64位Steam扣款協(xié)議ID
     * @return string|array|mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 15:36
     */
    function CancelAgreement($agreementid)
    {
        /**
         * 返回值
         * params
         *     agreementid - 唯一的 64 位 Steam 扣款協(xié)議 ID。
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_ADJUST_AGREEMENT), [
            'agreementid' => $agreementid,
        ]);
    }

    CONST URL_MICRO_TXN_FINALIZE_TXN = 'https://partner.steam-api.com/ISteamMicroTxn/FinalizeTxn/v2/';

    /**
     * 完成之前通過 InitTxn API 開始的購買愚隧。
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#FinalizeTxn
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#InitTxn 關于InitTxn
     * @param mixed $orderid 訂單的唯一 64 位 ID( version2開始支持字符串)
     * @return string|array|mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 15:39
     */
    function FinalizeTxn($orderid)
    {
        /**
         * 返回值
         * params
         *     orderid - 訂單的唯一 64 位 ID蒂阱。
         *     transid - 唯一的 64 位 Steam 交易 ID。
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_FINALIZE_TXN), [
            'orderid' => $orderid,
        ]);
    }

    CONST URL_MICRO_TXN_GET_REPORT = 'https://partner.steam-api.com/ISteamMicroTxn/GetReport/v4/';

    /**
     * Steam 提供可下載的交易報告狂塘,供您進行對賬蒜危。 這些報告含有各項交易中涉及資金結算入您的賬戶的詳細信息。
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#GetReport
     * @param string $datetime 報告的開始時間(Y-m-d H:i:s)睹耐。(RFC 3339 UTC 格式辐赞,如:2010-01-01T00:00:00Z, 此處由方法處理)
     * @param string $type 報告類型(以下其中之一:“GAMESALES”, “STEAMSTORESALES”, “SETTLEMENT”)
     * @param int $maxresults 報告中返回的結果的最大數量 (Default is 1000 if no value is set)
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 15:45
     */
    function GetReport($datetime, $type = 'GAMESALES', $maxresults = 1000)
    {
        /**
         * 返回值
         *    params
         *        time - Time of transaction (RFC 3339 UTC formatted like: 2010-01-01T00:00:00Z)
         *        orderid - Unique 64-bit ID for order. (This will be 0 for recurring subscriptions initiated from the Steam store, use transid instead.)
         *        transid - Unique 64-bit Steam transaction ID.
         *        steamid - The Steam ID of user that the order/transaction belongs to.
         *        status - Status of the order. See: 附錄 A:狀態(tài)值
         *        currency - ISO 4217 currency code.
         *        time - Time of the transaction. (RFC 3339 UTC formatted like: 2010-01-01T00:00:00Z)
         *        country - ISO 3166-1-alpha-2 country code.
         *        usstate - US State. Empty for non-US countries.
         *    items
         *        itemid - Game ID number of item.
         *        qty - Quantity of this item.
         *        amount - Total cost to user minus VAT (in cents). (199 = 1.99)
         *        vat - Total VAT or tax (in cents). (19 = .19)
         *        itemstatus - Status of items within the order.
         *        storepurchasereference - Optional, only returned if the purchase was via a DLC on the store that is connected to an in-game microtransaction item id.
         *            packageid - The DLC package that was purchased on the store.
         *            referenceid - The transid associated with the order.
         *            amount - The price paid by the user.
         *            vat - VAT taxes if applicable for the purchase.
         *            currency - The currency that was used to make the purchase.
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_GET_REPORT), [
            'time' => static::rfc3339($datetime),
            'type' => $type,
            'maxresults' => (int)$maxresults,
        ]);
    }

    /**
     * 獲取銷售報告
     * @param string $datetime
     * @param int $maxresults
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 15:57
     */
    function GetReport4GameSales($datetime, $maxresults = 1000)
    {
        return $this->GetReport($datetime, 'GAMESALES', $maxresults);
    }

    /**
     * 獲取Steam商店銷售報告
     * @param string $datetime
     * @param int $maxresults
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 15:58
     */
    function GetReport4SteamStoreSales($datetime, $maxresults = 1000)
    {
        return $this->GetReport($datetime, 'STEAMSTORESALES', $maxresults);
    }

    /**
     * 獲取Steam結算數據
     * @param string $datetime
     * @param int $maxresults
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 15:59
     */
    function GetReport4Settlement($datetime, $maxresults = 1000)
    {
        return $this->GetReport($datetime, 'SETTLEMENT', $maxresults);
    }

    CONST URL_MICRO_TXN_GET_USER_AGREEMENT_INFO = 'https://partner.steam-api.com/ISteamMicroTxn/GetUserAgreementInfo/v1/';

    /**
     * Get detailed information of all recurring billing agreements (subscriptions) for a user.
     * 獲取訂閱明細
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#GetUserAgreementInfo
     * @param mixed $steamid 客戶端的 Steam ID(不指定則用值域steamid)
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 16:03
     */
    function GetUserAgreementInfo($steamid = null)
    {
        /**
         * 返回值
         *    params
         *        agreements
         *            agreement
         *                agreementid - Unique 64-bit Steam billing agreement ID.
         *                itemid - Game ID number of item
         *                status - Active or canceled.
         *                period - Period of agreement.
         *                frequency - Interval of period.
         *                startdate - Date that recurring payment processing starts. Format is YYYYMMDD.
         *                enddate - Date that recurring payment processing ends. Format is YYYYMMDD.
         *                recurringamt - Amount to bill (in cents) at each recurring interval.
         *                currency - ISO 4217 currency code of prices.
         *                timecreated - Date that agreement was created in YYYYMMDD format.
         *                lastpayment - Date of last successful payment in YYYYMMDD format.
         *                lastamount - Amount of last successful payment in cents.
         *                nextpayment - Date of next scheduled payment in YYYYMMDD format.
         *                outstanding - Current outstanding balance in cents.
         *                failedattempts - Number of failed billing attempts on outstanding balance.
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_GET_USER_AGREEMENT_INFO), [
            'steamid' => $steamid,
        ]);
    }

    CONST URL_MICRO_TXN_GET_USER_INFO = 'https://partner.steam-api.com/ISteamMicroTxn/GetUserInfo/v2/';

    /**
     * 獲取用戶付費信息
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#GetUserInfo
     * @param mixed $steamid 進行購買的用戶的 Steam ID
     * @param mixed $ipaddress 用戶的 IP 地址,使用字符串格式 (xxx.xxx.xxx.xxx)硝训。 只在 InitTxn 的 usersession 設為 web 時才需要响委。
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 16:09
     */
    function GetUserInfo($steamid = null, $ipaddress = null)
    {
        /**
         * 返回值
         * params
         *     state - US State. Empty for non-US countries.
         *     country - ISO 3166-1-alpha-2 country code.
         *     currency - ISO 4217 currency code of prices.
         *     status - Status of the account. Can be either Active or Trusted. Trusted accounts have a have a known, good purchase history within Steam. Use this flag to relax your own fraud checking as appropriate.
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_GET_USER_INFO), [
            'key' => static::$steam->appkey,
            'steamid' => $steamid,
            '$ipaddress' => $ipaddress,
        ], true);
    }

    CONST URL_MICRO_TXN_INIT_TXN = 'https://partner.steam-api.com/ISteamMicroTxn/InitTxn/v3/';

    /**
     * 創(chuàng)建一個Steam訂單(此方法僅支持單個商品)
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#InitTxn
     * @param array $params
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 16:18
     */
    function InitTxn($params)
    {
        /**
         * 返回值
         * params
         *     orderid - Unique 64-bit ID for order. 自己的訂單號
         *     transid - Unique 64-bit Steam transaction ID. 事務Token
         *     steamurl - Optional URL returned when the usersession input is set to web. This URL can be used to redirect the user's web session to Steam so that the user can approve the transaction.
         *                steamurl在web版支付頁面時候用新思,Client下自己拉起Sdk窗即可
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_INIT_TXN), [
            'orderid' => $params['orderid'],    // 訂單的 64 位唯一 ID
            'itemcount' => $params['orderid'],  // 購物車中的物品數量
            'itemid[0]' => $params['itemid[0]'], // 物品的第三方 ID
            'qty[0]' => $params['qty[0]'], // 物品的數量, // 物品數量在v3時支持16bit數字, 65535
            'amount[0]' => $params['amount[0]'], // 總價格
            'description[0]' => $params['description[0]'], // 物品的描述

            // 默認配置,可以在SteamUtils方法調用前修改
            'language' => $params['language'] ?: static::$steam->language, // 物品描述的 ISO 639-1 語言代碼
            'currency' => $params['currency'] ?: static::$steam->currency,  // ISO 4217 貨幣代碼赘风。 參見支持幣種 @see https://partner.steamgames.com/doc/store/pricing/currencies

            // 非必須參數
            'usersession' => $params['usersession'], // 用戶將授權交易的會話夹囚。 有效選項為“client” 或 “web”。 如果未提供此參數邀窃,接口將假設是通過一個當前登錄的 Steam 客戶端會話進行荸哟。
            'ipaddress' => $params['ipaddress'], // 用戶的 IP 地址,使用字符串格式 (xxx.xxx.xxx.xxx)瞬捕。 只有在 [param]usersession[/param] 設為 web 時需要
            'category[0]' => $params['category[0]'], // 可選參數鞍历。物品的類別
            'associated_bundle[0]' => $params['associated_bundle[0]'], // 可選參數。相關聯(lián)的捆綁包的 bundleid
            'billingtype[0]' => $params['billingtype[0]'], // 可選參數肪虎。循環(huán)扣款類型
            'startdate[0]' => $params['startdate[0]'], // 可選參數劣砍。循環(huán)扣款的開始日期
            'enddate[0]' => $params['enddate[0]'], //可選參數。循環(huán)扣款的開始日期
            'period[0]' => $params['period[0]'], //可選參數扇救。循環(huán)扣款的開始日期
            'frequency[0]' => $params['frequency[0]'], // 可選參數刑枝。循環(huán)扣款的開始日期
            'recurringamt[0]' => $params['recurringamt[0]'], //可選參數。循環(huán)扣款的開始日期
            'bundlecount' => $params['bundlecount'], // 購物車中的捆綁包數量
            'bundleid[0]' => $params['bundleid[0]'], // 捆綁包的第三方 ID迅腔, 與第三方物品有相同的 ID 空間
            'bundle_qty[0]' => $params['bundle_qty[0]'], // 捆綁包的數量
            'bundle_desc[0]' => $params['bundle_desc[0]'], // 捆綁包的數量
            'bundle_category[0]' => $params['bundle_category[0]'], //   捆綁包的數量
        ]);
    }

    CONST URL_MICRO_TXN_PROCESS_AGREEMENT = 'https://partner.steam-api.com/ISteamMicroTxn/ProcessAgreement/v1/';

    /**
     * 申請一個訂閱訂單
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#ProcessAgreement
     * @param string $orderid 訂單的 64 位唯一 ID装畅。 對于通過 Steam 商店發(fā)起的循環(huán)訂閱,此字段將為 0
     * @param string $agreementid 唯一的 64 位 Steam 扣款協(xié)議 ID
     * @param int $amount 總費用(以分表示)沧烈。 此值與向用戶立即收取的初始一次性金額一致
     * @param string $currency 價格的 ISO 4217 貨幣代碼
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 16:39
     */
    function ProcessAgreement($orderid, $agreementid, $amount, $currency = null)
    {
        /**
         * 返回值
         * params
         *     orderid - Unique 64-bit ID for order. 自己的訂單號
         *     transid - Unique 64-bit Steam transaction ID. 事務Token
         *     agreementid - Steam單號
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_PROCESS_AGREEMENT), [
            'orderid' => $orderid,
            'agreementid' => $agreementid,
            'amount' => $amount,
            'currency' => $currency ?: static::$steam->currency,
        ]);
    }

    CONST URL_MICRO_TXN_QUERY_TXN = 'https://partner.steam-api.com/ISteamMicroTxn/QueryTxn/v2/';

    /**
     * 查詢交易(返回的是數組)
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#QueryTxn
     * @param string $orderid
     * @param string $transid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 16:45
     */
    function QueryTxn($orderid = null, $transid = null)
    {
        /**
         * 返回值
         * params
         *     orderid - 訂單的唯一 64 位 ID洁灵。
         *         transid - 唯一的 64 位 Steam 交易 ID。
         *         steamid - The Steam ID of user that the order/transaction belongs to.
         *         status - Status of the order. See: 附錄 A:狀態(tài)值
         *         currency - ISO 4217 currency code.
         *         time - Time of transaction (RFC 3339 UTC formatted like: 2010-01-01T00:00:00Z)
         *         country - ISO 3166-1-alpha-2 country code.
         *         usstate - US State. Empty for non-US countries.
         *         items
         *             itemid - Game ID number of item.
         *             qty - Quantity of this item.
         *             amount - Total cost to user minus VAT (in cents). (199 = 1.99)
         *             vat - Total VAT or tax (in cents). (19 = .19)
         *             itemstatus - Status of items within the order.
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_QUERY_TXN), [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'orderid' => $orderid,
            'transid' => $transid,
        ], true);
    }

    CONST URL_MICRO_TXN_REFUND_TXN = 'https://partner.steam-api.com/ISteamMicroTxn/RefundTxn/v2/';

    /**
     * 退單
     * @see https://partner.steamgames.com/doc/webapi/ISteamMicroTxn#RefundTxn
     * @param string $orderid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 16:48
     */
    function RefundTxn($orderid)
    {
        /**
         * 返回值
         * params
         *     orderid - 訂單的唯一 64 位 ID掺出。
         *     transid - 唯一的 64 位 Steam 交易 ID徽千。
         */
        return $this->post(static::parseUrl(static::URL_MICRO_TXN_REFUND_TXN), [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'orderid' => $orderid,
        ], true);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamNews 提供對 Steam 新聞功能的訪問
 * @see https://partner.steamgames.com/doc/webapi/ISteamNews
 * Author: Great Nomandia
 * Created At 2020/6/22 10:32
 */
class SteamUtils_ISteamNews extends SteamUtils_ISteam
{
    CONST URL_NEWS_GET_NEWS_FOR_APP = 'https://api.steampowered.com/ISteamNews/GetNewsForApp/v2/';

    /**
     * 獲得指定應用的新聞
     * @param int $enddate 獲取此日期之前的文章(unix 時間戳)
     * @param int $count 要獲取的文章數量(默認為 20)
     * @param string $feeds 要返回新聞的 feed 名稱列表,以逗號分隔
     * @param int $maxlength 返回的內容的最大長度汤锨。如果為 0双抽,返回完整內容。如果最大長度不夠闲礼,則生成一個符合長度的片斷
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamNews#GetNewsForApp
     * Author: Great Nomandia
     * Created At 2020/6/22 10:30
     */
    function GetNewsForApp($enddate = null, $count = 20, $feeds = null, $maxlength = 0)
    {
        return $this->get(self::URL_NEWS_GET_NEWS_FOR_APP, [
            'appid' => static::$steam->appid,
            'maxlength' => $maxlength,
            'enddate' => $enddate,
            'count' => $count,
            'feeds' => $feeds,
        ]);
    }

    CONST URL_NEWS_GET_NEWS_FOR_APP_AUTHED = 'https://partner.steam-api.com/ISteamNews/GetNewsForAppAuthed/v2/';

    /**
     * 獲得指定應用的新聞(舊版接口不再支持了, 目前實現(xiàn)為新版的接口)
     * @param int $enddate 獲取此日期之前的文章(unix 時間戳)
     * @param int $count 要獲取的文章數量(默認為 20)
     * @param string $feeds 要返回新聞的 feed 名稱列表牍汹,以逗號分隔
     * @param int $maxlength 返回的內容的最大長度。如果為 0柬泽,返回完整內容慎菲。如果最大長度不夠,則生成一個符合長度的片斷
     * @return array|mixed|string
     * @see https://partner.steamgames.com/doc/webapi/ISteamNews#GetNewsForAppAuthed
     * Author: Great Nomandia
     * Created At 2020/6/22 10:34
     */
    function GetNewsForAppAuthed($enddate = null, $count = 20, $feeds = null, $maxlength = 0)
    {
        return $this->GetNewsForApp($enddate, $count, $feeds, $maxlength);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamUserAuth - 訪問用戶相關的信息
 * @see https://partner.steamgames.com/doc/webapi/ISteamUserAuth
 * Author: Great Nomandia
 * Created At 2020/6/19 17:04
 */
class SteamUtils_ISteamUserAuth extends SteamUtils_ISteam
{
    CONST URL_AUTHENTICATE_USER = 'https://api.steampowered.com/ISteamUserAuth/AuthenticateUser/v1/';

    /**
     * 驗證登錄
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserAuth#AuthenticateUser
     * @param string $steamid
     * @param string $encrypted_loginkey
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:07
     */
    function AuthenticateUser($steamid, $encrypted_loginkey)
    {
        return $this->post(static::URL_AUTHENTICATE_USER, [
            'steamid' => $steamid,
            'sessionkey' => $sessionkey, // 隨機RSA文本
            'encrypted_loginkey' => $encrypted_loginkey,
        ], true);
    }

    CONST URL_AUTHENTICATE_USER_TICKET = 'https://api.steampowered.com/ISteamUserAuth/AuthenticateUserTicket/v1/';

    /**
     * 驗證票據
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserAuth#AuthenticateUserTicket
     * @param string $ticket 將 GetAuthSessionTicket 的 ticket 從二進制轉換為十六進制锨并,轉換為大小合適的字節(jié)字符數組露该,并將結果作為此 ticket 參數傳遞進來。
     * @return string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:11
     */
    function AuthenticateUserTicket($ticket)
    {
        return $this->get(static::URL_AUTHENTICATE_USER_TICKET, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'ticket' => $ticket,
        ], true);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamUserStats - 用于訪問關于用戶的信息
 * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats
 * Author: Great Nomandia
 * Created At 2020/6/19 17:13
 */
class SteamUtils_ISteamUserStats extends SteamUtils_ISteam
{
    CONST URL_GET_GLOBAL_ACHIEVEMENT_PERCENTAGE_FOR_APP = 'https://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v2/';

    /**
     * 為指定應用獲取全局成就百分比
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats#GetGlobalAchievementPercentagesForApp
     * @param int $gameid 要獲取成就百分比的 GameID
     * @return string|array|mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 17:16
     */
    function GetGlobalAchievementPercentagesForApp($gameid)
    {
        return $this->get(static::URL_GET_GLOBAL_ACHIEVEMENT_PERCENTAGE_FOR_APP, [
            'gameid' => $gameid ?: static::$steam->gameid
        ], true);
    }

    CONST URL_GET_GLOBAL_STATS_FOR_GAME = 'https://api.steampowered.com/ISteamUserStats/GetGlobalStatsForGame/v1/';

    /**
     * Retrieves the global stats percentages for the specified app
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats#GetGlobalStatsForGame
     * @param int $count 要獲取數據的統(tǒng)計的數量
     * @param string $name 要獲取數據的統(tǒng)計的名稱
     * @param int $startdate 每日合計的開始日期(unix 時間戳)
     * @param int $enddate 每日合計的結束日期(unix 時間戳)
     * @return string|array|mixed
     * Author: Great Nomandia
     * Created At 2020/6/19 17:18
     */
    function GetGlobalStatsForGame($count, $name, $startdate, $enddate)
    {
        return $this->get(static::URL_GET_GLOBAL_STATS_FOR_GAME, [
            'appid' => static::$steam->appid,
            'count' => $count,
            'name[0]' => $name,
            'startdate' => $startdate,
            'enddate' => $enddate,
        ], true);
    }

    CONST URL_GET_NUMBER_OF_CURRENT_PLAYERS = 'https://api.steampowered.com/ISteamUserStats/GetNumberOfCurrentPlayers/v1/';

    /**
     * 獲得指定應用當前在 Steam 上的活躍玩家的總數量
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats#GetNumberOfCurrentPlayers
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:21
     */
    function GetNumberOfCurrentPlayers()
    {
        return $this->get(static::URL_GET_NUMBER_OF_CURRENT_PLAYERS, [
            'appid' => static::$steam->appid,
        ], true);
    }

    CONST URL_GET_PLAYER_ACHIEVEMENTS = 'https://api.steampowered.com/ISteamUserStats/GetPlayerAchievements/v1/';

    /**
     * 獲得指定用戶在一個應用中已解鎖的成就列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats#GetPlayerAchievements
     * @param string $steamid
     * @param string $language 返回字符串的語言
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:24
     */
    function GetPlayerAchievements($steamid = null, $language = null)
    {
        return $this->get(static::URL_GET_PLAYER_ACHIEVEMENTS, [
            'steamid' => $steamid,
            'l' => $language ?: static::$steam->language,
        ]);
    }

    CONST URL_GET_SCHEMA_FOR_GAME = 'https://api.steampowered.com/ISteamUserStats/GetSchemaForGame/v2/';

    /**
     * 獲得指定游戲的統(tǒng)計與成就的完整列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats#GetSchemaForGame
     * @param string $language
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:25
     */
    function GetSchemaForGame($language = null)
    {
        return $this->get(static::URL_GET_PLAYER_ACHIEVEMENTS, [
            'key' => static::$steam->appkey,
            'appid' => static::$steam->appid,
            'l' => $language ?: static::$steam->language,
        ], true);
    }

    CONST URL_GET_USER_STATS_FOR_GAME = 'https://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v2/';

    /**
     * 獲得指定用戶在一個應用中設置的統(tǒng)計列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats#GetUserStatsForGame
     * @param string $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:27
     */
    function GetUserStatsForGame($steamid = null)
    {
        return $this->get(static::URL_GET_USER_STATS_FOR_GAME, [
            'steamid' => $steamid,
        ]);
    }

    CONST URL_SET_USER_STATS_FOR_GAME = 'https://partner.steam-api.com/ISteamUserStats/SetUserStatsForGame/v1/';

    /**
     * 為游戲設置指定用戶的統(tǒng)計
     * @see https://partner.steamgames.com/doc/webapi/ISteamUserStats#SetUserStatsForGame
     * @param int $count 要設置值的統(tǒng)計與成就的數量(名稱/值參數對)
     * @param string $name 要設置的統(tǒng)計與成就的名稱
     * @param int $value 要設置的值
     * @param string $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:28
     */
    function SetUserStatsForGame($count, $name, $value, $steamid = null)
    {
        return $this->post(static::URL_SET_USER_STATS_FOR_GAME, [
            'steamid' => $steamid,
            'count' => $count,
            'name[0]' => $name,
            'value[0]' => $value,
        ]);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamUser - 用于訪問信息并與用戶交互
 * @see https://partner.steamgames.com/doc/webapi/ISteamUser
 * Author: Great Nomandia
 * Created At 2020/6/19 17:32
 */
class SteamUtils_ISteamUser extends SteamUtils_ISteam
{

    CONST URL_CHECK_APP_OWNER_SHIP = 'https://partner.steam-api.com/ISteamUser/CheckAppOwnership/v2/';

    /**
     * 查看是否指定用戶擁有該應用
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#CheckAppOwnership
     * @param string $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:33
     */
    function CheckAppOwnership($steamid = null)
    {
        /**
         * 返回值
         * ownsapp:指明用戶是實際所有者或應用
         * permanent:Indicates if the user owns the app permanently.
         * timestamp:獲取該應用的時間
         * ownersteamid:指明該應用的真正所有者
         * sitelicense:Indicates if user is borrowing this license from a PC Cafe site
         */
        return $this->get(static::URL_CHECK_APP_OWNER_SHIP, [
            'steamid' => $steamid,
        ]);
    }

    CONST URL_GET_APP_PRICE_INFO = 'https://partner.steam-api.com/ISteamUser/GetAppPriceInfo/v1/';

    /**
     * 獲取APP的價格信息
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GetAppPriceInfo
     * @param string $appids appid逗號,分隔
     * @param string $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:36
     */
    function GetAppPriceInfo($appids, $steamid = null)
    {
        return $this->get(static::URL_GET_APP_PRICE_INFO, [
            'key' => static::$steam->appkey,
            'steamid' => $steamid ?: static::$steam->steamid,
            'appids' => $appids,
        ], true);
    }

    CONST URL_GET_FRIEND_LIST = 'https://api.steampowered.com/ISteamUser/GetFriendList/v1/';

    /**
     * 獲取好友列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GetFriendList
     * @param string $relationship
     * @param string $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:39
     */
    function GetFriendList($relationship, $steamid = null)
    {
        return $this->get(static::URL_GET_FRIEND_LIST, [
            'key' => static::$steam->appkey,
            'steamid' => $steamid ?: static::$steam->steamid,
            'relationship' => $relationship,
        ], true);
    }

    CONST URL_GET_PLAY_BANS = 'https://api.steampowered.com/ISteamUser/GetPlayerBans/v1/';

    /**
     * 獲取賬號屏蔽信息
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GetPlayerBans
     * @param string $steamids
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:41
     */
    function GetPlayerBans($steamids)
    {
        return $this->get(static::URL_GET_PLAY_BANS, [
            'key' => static::$steam->appkey,
            'steamids' => $steamids,
        ], true);
    }

    CONST URL_GET_PLAYER_SUMMARIES = 'https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/';

    /**
     * 獲取玩家匯總數據
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GetPlayerSummaries
     * @param string $steamids
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:43
     */
    function GetPlayerSummaries($steamids)
    {
        /**
         * 返回值類似
         * "response":{
         * "players":[
         * {
         * "steamid":"77561198355051011",
         * "communityvisibilitystate":1,
         * "profilestate":1,
         * "personaname":"Mister Manager",
         * "lastlogoff":1556305001,
         * "profileurl":"https://steamcommunity.com/profiles/77561198355051011/",
         * "avatar":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/32/32f70a383a437d03af91d2f01a0776adf75201b5.jpg",
         * "avatarmedium":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/32/32f70a383a437d03af91d2f01a0776adf75201b5_medium.jpg",
         * "avatarfull":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/32/32f70a383a437d03af91d2f01a0776adf75201b5_full.jpg",
         * }
         * ]
         * }
         */
        return $this->get(static::URL_GET_PLAYER_SUMMARIES, [
            'key' => static::$steam->appkey,
            'steamids' => $steamids,
        ], true);
    }

    CONST URL_GET_PUBLISHER_APP_OWNERSHIP = 'https://partner.steam-api.com/ISteamUser/GetPublisherAppOwnership/v3/';

    /**
     * 獲取玩家擁有的app
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GetPublisherAppOwnership
     * @param string $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:46
     */
    function GetPublisherAppOwnership($steamid = null)
    {
        /**
         * "appownership":{
         * "apps":[
         * {
         * "appid":60,
         * "ownsapp":true, // 是否買了此游戲第煮,Whether the user currently owns your game. 將對通過購買解幼、序列號抑党、家庭共享、免費周末以及站點許可獲得的所有權有效撵摆。
         * "permanent":true, // 購買時效底靠,true=永久 Whether the user permanetly owns your game. 對通過家庭共享、免費周末特铝、站點許可獲得的所有權無效暑中。
         * "timestamp":"2005-04-03T17:50:29Z", // GMT time for when the user first accquired the appID
         * "ownersteamid":"76561197978236369", //    SteamID for the actual owner. If the app is owned via Family Sharing, ownersteamid will be the actual owner. Otherwise will be the same steamID passed in
         * "sitelicense":"false" // 指明用戶是否從商用站點借用此許可。
         * }
         * ]
         * }
         */
        return $this->get(static::URL_GET_PUBLISHER_APP_OWNERSHIP, [
            'key' => static::$steam->appkey,
            'steamid' => $steamid ?: static::$steam->steamid,
        ], true);
    }

    CONST URL_GET_PUBLISHER_APP_OWNERSHIP_CHANGES = 'https://partner.steam-api.com/ISteamUser/GetPublisherAppOwnershipChanges/v1/';

    /**
     * 獲取哪些用戶可以對指定版本具有所有權
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GetPublisherAppOwnershipChanges
     * @param string $packagerowversion
     * @param string $cdkeyrowversion
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:50
     */
    function GetPublisherAppOwnershipChanges($packagerowversion, $cdkeyrowversion)
    {
        /**
         * "ownershipchanges": {
         * "steamids": [
         * {
         * "steamid": "76561198114498811"
         * },
         * {
         * "steamid": "76561198114498812"
         * },
         * ...
         * ],
         * "packagerowversion": "12448390228",
         * "cdkeyrowversion": "49857241147",
         * "moredata": true
         * }
         */
        return $this->get(static::URL_GET_PUBLISHER_APP_OWNERSHIP_CHANGES, [
            'key' => static::$steam->appkey,
            'packagerowversion' => $packagerowversion,
            'cdkeyrowversion' => $cdkeyrowversion,
        ], true);
    }

    CONST URL_GET_USER_GROUP_LIST = 'https://api.steampowered.com/ISteamUser/GetUserGroupList/v1/';

    /**
     * 獲取用戶所在的分組
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GetUserGroupList
     * @param string $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:54
     */
    function GetUserGroupList($steamid = null)
    {
        return $this->get(static::URL_GET_USER_GROUP_LIST, [
            'key' => static::$steam->appkey,
            'steamid' => $steamid ?: static::$steam->steamid,
        ], true);
    }

    CONST URL_GRANT_PACKAGE = 'https://partner.steam-api.com/ISteamUser/GrantPackage/v1/';

    /**
     * 第三方發(fā)放授權包鲫剿?
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#GrantPackage
     * @param string $packageid PackageID to grant
     * @param string $ipaddress ip address of user in string format (xxx.xxx.xxx.xxx).
     * @param string $thirdpartykey Optionally associate third party key during grant. 'thirdpartyappid' will have to be set.
     * @param string $thirdpartyappid Has to be set if 'thirdpartykey' is set. The appid associated with the 'thirdpartykey'.
     * @param null $steamid
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 17:56
     */
    function GrantPackage($packageid, $ipaddress, $thirdpartykey, $thirdpartyappid, $steamid = null)
    {
        return $this->get(static::URL_GET_USER_GROUP_LIST, [
            'key' => static::$steam->appkey,
            'steamid' => $steamid ?: static::$steam->steamid,
            'packageid' => $packageid,
            'ipaddress' => $ipaddress,
            'thirdpartykey' => $thirdpartykey,
            'thirdpartyappid' => $thirdpartyappid,
        ], true);
    }

    CONST URL_RESOLVE_VANITY_URL = 'https://api.steampowered.com/ISteamUser/ResolveVanityURL/v1/';

    /**
     * 解析一個偽地址(應該是返回一個鏈接)
     * @see https://partner.steamgames.com/doc/webapi/ISteamUser#ResolveVanityURL
     * @param string $vanityurl 虛擬URL The vanity URL to get a SteamID for
     * @param int $url_type The type of vanity URL. 1 (default): 玩家信息Individual profile, 2: 分組Group, 3: 官網Official game group
     * Author: Great Nomandia
     * Created At 2020/6/19 17:58
     * @return array|mixed|string
     */
    function ResolveVanityURL($vanityurl, $url_type = 1)
    {
        return $this->get(static::URL_GET_USER_GROUP_LIST, [
            'key' => static::$steam->appkey,
            'vanityurl' => $vanityurl,
            'url_type' => $url_type,
        ], true);
    }
}

/**
 * YCZ - Class SteamUtils_ISteamWebAPIUtil - 獲取Steam相關數據
 * @see https://partner.steamgames.com/doc/webapi/ISteamWebAPIUtil
 * Author: Great Nomandia
 * Created At 2020/6/19 18:06
 */
class SteamUtils_ISteamWebAPIUtil extends SteamUtils_ISteam
{
    CONST URL_GET_SERVER_INFO = 'https://api.steampowered.com/ISteamWebAPIUtil/GetServerInfo/v1/';

    /**
     * 獲撒狻(Steam)服務器信息?
     * @see https://partner.steamgames.com/doc/webapi/ISteamWebAPIUtil#GetServerInfo
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:07
     */
    function GetServerInfo()
    {
        return $this->get(static::URL_GET_SERVER_INFO);
    }

    CONST URL_GET_SUPPORT_API_LIST = 'https://api.steampowered.com/ISteamWebAPIUtil/GetSupportedAPIList/v1/';

    /**
     * 獲取支持的API列表
     * @see https://partner.steamgames.com/doc/webapi/ISteamWebAPIUtil#GetSupportedAPIList
     * @return array|mixed|string
     * Author: Great Nomandia
     * Created At 2020/6/19 18:08
     */
    function GetSupportedAPIList()
    {
        return $this->get(static::URL_GET_SUPPORT_API_LIST);
    }
}
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末牵素,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子澄者,更是在濱河造成了極大的恐慌笆呆,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,252評論 6 516
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件粱挡,死亡現(xiàn)場離奇詭異赠幕,居然都是意外死亡,警方通過查閱死者的電腦和手機询筏,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,886評論 3 399
  • 文/潘曉璐 我一進店門榕堰,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人嫌套,你說我怎么就攤上這事逆屡。” “怎么了踱讨?”我有些...
    開封第一講書人閱讀 168,814評論 0 361
  • 文/不壞的土叔 我叫張陵魏蔗,是天一觀的道長。 經常有香客問我痹筛,道長莺治,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,869評論 1 299
  • 正文 為了忘掉前任帚稠,我火速辦了婚禮谣旁,結果婚禮上,老公的妹妹穿的比我還像新娘滋早。我一直安慰自己榄审,他們只是感情好,可當我...
    茶點故事閱讀 68,888評論 6 398
  • 文/花漫 我一把揭開白布杆麸。 她就那樣靜靜地躺著瘟判,像睡著了一般怨绣。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上拷获,一...
    開封第一講書人閱讀 52,475評論 1 312
  • 那天篮撑,我揣著相機與錄音,去河邊找鬼匆瓜。 笑死赢笨,一個胖子當著我的面吹牛,可吹牛的內容都是我干的驮吱。 我是一名探鬼主播茧妒,決...
    沈念sama閱讀 41,010評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼左冬!你這毒婦竟也來了桐筏?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 39,924評論 0 277
  • 序言:老撾萬榮一對情侶失蹤拇砰,失蹤者是張志新(化名)和其女友劉穎梅忌,沒想到半個月后,有當地人在樹林里發(fā)現(xiàn)了一具尸體除破,經...
    沈念sama閱讀 46,469評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡牧氮,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 38,552評論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了瑰枫。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片踱葛。...
    茶點故事閱讀 40,680評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖光坝,靈堂內的尸體忽然破棺而出尸诽,到底是詐尸還是另有隱情,我是刑警寧澤盯另,帶...
    沈念sama閱讀 36,362評論 5 351
  • 正文 年R本政府宣布逊谋,位于F島的核電站,受9級特大地震影響土铺,放射性物質發(fā)生泄漏胶滋。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 42,037評論 3 335
  • 文/蒙蒙 一悲敷、第九天 我趴在偏房一處隱蔽的房頂上張望究恤。 院中可真熱鬧,春花似錦后德、人聲如沸部宿。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,519評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽理张。三九已至赫蛇,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間雾叭,已是汗流浹背悟耘。 一陣腳步聲響...
    開封第一講書人閱讀 33,621評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留织狐,地道東北人暂幼。 一個月前我還...
    沈念sama閱讀 49,099評論 3 378
  • 正文 我出身青樓,卻偏偏與公主長得像移迫,于是被迫代替她去往敵國和親旺嬉。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,691評論 2 361