0
我有一个Java蒸汽交易机器人,可以通过蒸汽读取未完成的贸易优惠并根据需求降低它们。我正在使用官方Web API(使用来自http://steamcommunity.com/dev/apikey的API密钥)将请求传递给Steam。变量trade
来自我自己的API接口(我已经调试过并且适用于拒绝优惠)。接受来自Steam的使用Web-API和Java的贸易优惠
SteamPlug.steamRequest(method, query);
仅仅是一个基本的HTTP请求:
public static String steamRequest(String method, String query) {
try {
URL obj = new URL(query);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod(method);
int responseCode = con.getResponseCode();
if (responseCode != 200 && responseCode != 201) {
return "ERR" + responseCode;
}
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
} catch (MalformedURLException | ProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
// Ignored
}
return null;
}
这是怎么拒绝贸易提供:
SteamPlug.steamRequest(
"POST",
"http://api.steampowered.com/IEconService/DeclineTradeOffer/v0001/?key="
+ SteamPlug.API_KEY + "&tradeofferid=" + trade.getTradeOfferId()
);
我所试图做的是接受行业也是如此。我曾经尝试这样做:
SteamPlug.steamRequest(
"POST",
"https://steamcommunity.com/tradeoffer/" + trade.getTradeOfferId() + "/accept?key="
+ SteamPlug.API_KEY
);
但是我收到一个411 Length Required
响应。
我相信我可以通过使用Steam会话认证来接受优惠,但可以仅使用用户的Web-API密钥接受交易优惠吗?
是的我已阅读过这些文档。不过,我相信另一种解决方法是让机器人发送报价,尽管这也没有记录。 – Momo
好枪是反对蒸汽ToS(至少市场部分),所以我非常怀疑API将允许发送或接受交易。 Plus API主要用于扩展和东西,因此允许以这种方式接受交易是不安全的。 –